Created
April 14, 2020 01:08
-
-
Save jeanmidevacc/801171ec7c279526b968d67ca618eb83 to your computer and use it in GitHub Desktop.
This file contains 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
import tensorflow as tf | |
model = tf.keras.models.Sequential([ | |
tf.keras.layers.Conv2D(16, 3, padding='same', activation='relu', input_shape=(IMG_HEIGHT, IMG_WIDTH ,3)), | |
tf.keras.layers.MaxPooling2D(), | |
tf.keras.layers.Conv2D(32, 3, padding='same', activation='relu'), | |
tf.keras.layers.MaxPooling2D(), | |
tf.keras.layers.Conv2D(64, 3, padding='same', activation='relu'), | |
tf.keras.layers.MaxPooling2D(), | |
tf.keras.layers.Flatten(), | |
tf.keras.layers.Dense(512, activation='relu'), | |
tf.keras.layers.Dense(len(CLASS_NAMES)) | |
]) | |
model.compile(optimizer='adam', | |
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True), | |
metrics=['accuracy']) | |
# Setup the tensorboard connect | |
log_dir = "logs\\fit\\" + 'tensorflowtuto_' + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") | |
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1) | |
history = model.fit( | |
train_data_gen, | |
steps_per_epoch=image_count_train // BATCH_SIZE, | |
epochs=EPOCHS, | |
validation_data=val_data_gen, | |
validation_steps=image_count_validation // BATCH_SIZE, | |
callbacks=[tensorboard_callback] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment