o Yuki - #2
Open
Erwanrevirand45 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
import tensorflow as tf
from tensorflow.keras import layers, models
Charger les données d'entraînement (par exemple, depuis TensorFlow datasets)
(train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.mnist.load_data()
Prétraiter les données
train_images = train_images / 255.0
test_images = test_images / 255.0
Construire le modèle
model = models.Sequential([
layers.Flatten(input_shape=(28, 28)), # Aplatir l'image en une seule dimension
layers.Dense(128, activation='relu'), # Couche cachée avec 128 neurones et activation relu
layers.Dense(10, activation='softmax') # Couche de sortie avec 10 neurones (pour les 10 classes) et activation softmax
])
Compiler le modèle
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
Entraîner le modèle
model.fit(train_images, train_labels, epochs=10, validation_data=(test_images, test_labels))
Évaluer le modèle
test_loss, test_acc = model.evaluate(test_images, test_labels)
print('Test accuracy:', test_acc)