CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
huggingface

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: huggingface/notebooks
Path: blob/main/course/fr/chapter2/section3_tf.ipynb
Views: 2555
Kernel: Python 3

Modèles (TensorFlow)

Installez la bibliothèque 🤗 Transformers pour exécuter ce notebook.

!pip install transformers[sentencepiece]
from transformers import CamembertConfig, TFCamembertModel # Construire la configuration config = CamembertConfig() # Construire le modèle à partir de la configuration model = TFCamembertModel(config)
print(config)
from transformers import CamembertConfig, TFCamembertModel config = CamembertConfig() model = TFCamembertModel(config) # Le modèle est initialisé de façon aléatoire !
from transformers import TFCamembertModel model = TFCamembertModel.from_pretrained("camembert-base")
model.save_pretrained("directory_on_my_computer")
sequences = ["Hello!", "Cool.", "Nice!"]
from transformers import CamembertTokenizer tokenizer = CamembertTokenizer.from_pretrained("camembert-base") encoded_sequences = tokenizer(sequences) encoded_sequences
import tensorflow as tf model_inputs = tf.constant(encoded_sequences)
output = model(model_inputs)