<jupyter_start><jupyter_text>Quick Start: TF Watcher![](https://i.imgur.com/C1EuWC2.png)What if you could monitor your Machine Learning jobs on Colab, Kaggle, AzureML, or pretty much anywhere on your mobile phones, so you could monitor your models on the fly. Even while taking a walk🚶in < 5 lines of code!Consider giving a star⭐ to [the project](https://github.com/Rishit-dagli/TF-Watcher) if you like it.In this example we’ll use the [Fashion MNIST dataset](https://www.tensorflow.org/api_docs/python/tf/keras/datasets/fashion_mnist) to serve as a quickstart.  SetupWe start off by installing TF Watcher from PyPI.<jupyter_code>!pip install tf-watcher
import tensorflow as tf
from tensorflow import keras
import tfwatcher<jupyter_output><empty_output><jupyter_text>Get the data<jupyter_code># Load example MNIST data and pre-process it
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()<jupyter_output>Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
11493376/11490434 [==============================] - 0s 0us/step<jupyter_text>Some simple pre-processing<jupyter_code>x_train = x_train.reshape(-1, 784).astype("float32") / 255.0
x_test = x_test.reshape(-1, 784).astype("float32") / 255.0

# Limit the data to 1000 samples
x_train = x_train[:1000]
y_train = y_train[:1000]
x_test = x_test[:1000]
y_test = y_test[:1000]<jupyter_output><empty_output><jupyter_text>Create a simple modelNote the `metrics` argument in `model.compile`, specify any additional metrics you want to log from here.<jupyter_code># Define the Keras model to add callbacks to
def get_model():
    model = keras.Sequential()
    model.add(keras.layers.Dense(1, input_dim=784))
    model.compile(
        optimizer=keras.optimizers.RMSprop(learning_rate=0.1),
        loss="mean_squared_error",
        metrics=["accuracy"],
    )
    return model<jupyter_output><empty_output><jupyter_text>Use TF Watcher while training- We use the `EpochEnd` class from TF Watcher to specify we are interested in operating in the epoch level- We pass in `schedule` as 1 to monitor after every epoch. You could pass in this as 3 to monitor after every 3 epochs or also pass in a list of the specific epoch number you want to monitor on<jupyter_code>MonitorCallback = tfwatcher.callbacks.EpochEnd(schedule = 1)<jupyter_output>Use this ID to monitor training for this session: ybhzyxK<jupyter_text>We will now use this ID on https://www.tfwatcher.tech to monitor our model<jupyter_code>model = get_model()
history = model.fit(
    x_train,
    y_train,
    batch_size=128,
    epochs=100,
    validation_split=0.5,
    callbacks = [MonitorCallback]
)<jupyter_output>Epoch 1/100
4/4 [==============================] - 1s 58ms/step - loss: 220.0279 - accuracy: 0.1400 - val_loss: 7.1787 - val_accuracy: 0.1000
Epoch 2/100
4/4 [==============================] - 0s 9ms/step - loss: 5.8449 - accuracy: 0.1400 - val_loss: 5.6531 - val_accuracy: 0.1240
Epoch 3/100
4/4 [==============================] - 0s 10ms/step - loss: 4.3850 - accuracy: 0.1580 - val_loss: 4.7036 - val_accuracy: 0.1160
Epoch 4/100
4/4 [==============================] - 0s 9ms/step - loss: 3.6359 - accuracy: 0.1700 - val_loss: 5.1514 - val_accuracy: 0.1040
Epoch 5/100
4/4 [==============================] - 0s 10ms/step - loss: 22.7958 - accuracy: 0.1500 - val_loss: 94.3385 - val_accuracy: 0.1000
Epoch 6/100
4/4 [==============================] - 0s 11ms/step - loss: 66.1149 - accuracy: 0.1160 - val_loss: 38.9990 - val_accuracy: 0.1000
Epoch 7/100
4/4 [==============================] - 0s 10ms/step - loss: 23.7571 - accuracy: 0.1280 - val_loss: 16.4039 - val_accuracy: 0.1000
Epoch 8/100
4/[...]
{'fraction_non_alphanumeric': 0.17095638038471958, 'fraction_numerical': 0.07938228122460038, 'mean_word_length': 4.636641221374046, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 22, 'https://': 5, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '640973', 'license': 'Apache-2.0', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1260, 'n_words': 356, 'path': 'docs/source/TF-Watcher-Quickstart.ipynb', 'repo_name': 'Rishit-dagli/TF-Watcher', 'size': '3691'}