Created
August 30, 2022 08:44
-
-
Save ayulockin/76f68cb4145df41accbb95ff2eda5b39 to your computer and use it in GitHub Desktop.
Manual test for new W&B Keras Metrics Logger.
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 | |
import wandb | |
from wandb.keras import WandBMetricsLogger | |
with wandb.init(project="mnist", job_type="dev-wandb-metrics-logger"): | |
fashion_mnist = tf.keras.datasets.fashion_mnist | |
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() | |
train_images = train_images / 255.0 | |
test_images = test_images / 255.0 | |
model = tf.keras.Sequential( | |
[ | |
tf.keras.layers.Flatten(input_shape=(28, 28)), | |
tf.keras.layers.Dense(128, activation="relu"), | |
tf.keras.layers.Dense(10), | |
] | |
) | |
model.compile( | |
optimizer="adam", | |
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True), | |
metrics=["accuracy"], | |
) | |
callbacks = [ | |
WandBMetricsLogger(log_batch_frequency=10) | |
] | |
model.fit( | |
train_images, | |
train_labels, | |
epochs=1, | |
callbacks=callbacks, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment