MLDashboard
Monitoring solution for tensorflow training. Particulary useful for image classification models. Not compatible with google colab or other notebook based runtimes.
Getting Started
This guide assumes you already understand python and tensorflow.
Installation
pip install MLDashboard
Examples
See Examples for usage.
Quick Start
To start, you need a dashboard.json config file. This should be in the same directory as your script. Here is an example:
{
"modules":[
[
["LossMetricsGraph", {}],
["LossMetricsNumerical", {}]
],
[
["StatusModule",{}],
["EmptyModule", {}]
]
]
}
NOTE: All code in this demo should be protected by
if __name__ == '__main__':
to prevent multiprocessing conflicts.
The dashboard can easily by added to an existing machine learning project. Import the dashboard as shown.
from MLDashboard.MLDashboardBackend import createDashboard
from MLDashboard.MLCallbacksBackend import DashboardCallbacks, CallbackConfig
from MLDashboard.MLCommunicationBackend import Message, MessageMode
Before training starts, create the dashboard.
#MAKE SURE YOU HAVE A DASHBOARD.JSON FILE IN THE SAME DIRECTORY AS YOUR SCRIPT
dashboardProcess, updatelist, returnlist = createDashboard(config='dashboard.json')
Connect the callbacks to your training.
config = CallbackConfig()
labels = list(range(0,10)) #labels should be customized for the data. This is for mnist number recognition
callback = DashboardCallbacks(updatelist, returnlist, model, x_train, y_train, x_test, y_test, labels, config)
model.fit(x_train, y_train, epochs=10, callbacks=[callback])
After training ends, you can send evaluation stats to the dashboard.
model.evaluate(x_test, y_test, batch_size=128, callbacks=[callback])
To exit the dashboard cleanly, use the following code:
updatelist.append(Message(MessageMode.End, {}))
print("Exiting cleanly...")
dashboardProcess.join()
print("Dashboard exited.")
#This handles any extra data that the dashboard sent, such as save commands
callback.HandleRemaingCommands()
Here is a full example with python code:
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2' #stops agressive error message printing
import tensorflow as tf
from tensorflow import keras
from MLDashboard.MLDashboardBackend import createDashboard
from MLDashboard.MLCallbacksBackend import DashboardCallbacks, CallbackConfig
from MLDashboard.MLCommunicationBackend import Message, MessageMode
def run():
print("Starting interactive dashboard demo...")
print("Setting up dashboard...")
#Create dashboard and return communication tools (this starts the process)
#MAKE SURE YOU HAVE A DASHBOARD.JSON FILE IN THE SAME DIRECTORY AS YOUR SCRIPT
dashboardProcess, updatelist, returnlist = createDashboard(config='dashboard.json')
print("Loading data...")
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
print("Formatting data...")
x_train = x_train.reshape(-1, 784).astype("float32") / 255.0
x_test = x_test.reshape(-1, 784).astype("float32") / 255.0
print("Sampling data...")
# Limit the train data to 10000 samples
x_train = x_train[:10000]
y_train = y_train[:10000]
# Limit test data to 1000 samples
x_test = x_test[:1000]
y_test = y_test[:1000]
print("Creating model...")
model = keras.Sequential([keras.layers.Dense(128, activation='relu'), keras.layers.Dense(10)])
model.compile(optimizer='adam', metrics=["accuracy"],
loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True))
print("Creating callbacks...")
#Callbacks require update and return list for communicating with dashboard
#Model and datasets are useful for sending that data to certain modules
config = CallbackConfig()
labels = list(range(0,10))
callback = DashboardCallbacks(updatelist, returnlist, model, x_train, y_train, x_test, y_test, labels, config)
model.fit(x_train, y_train, epochs=50, callbacks=[callback])
print("Evaluating model...")
#This is connected to the callback so the data is sent to the dashboard
model.evaluate(x_test, y_test, batch_size=128, callbacks=[callback])
updatelist.append(Message(MessageMode.End, {}))
print("Exiting cleanly...")
dashboardProcess.join()
print("Dashboard exited.")
#This handles any extra data that the dashboard sent, such as save commands
callback.HandleRemaingCommands()
if __name__ == '__main__':
run()
Other guides:
Metadata
Release files for MLDashboard 1.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mldashboard-1.4.5.tar.gz | 71.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mldashboard-1.4.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 148.9 kB
Release files / mldashboard-1.4.5.tar.gz
| Download URL | mldashboard-1.4.5.tar.gz |
|---|---|
| Size | 71.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3d5933d181fa868728307999057fb9494d191848271edcfbddaf37dcd36a999
|
|
BLAKE2b-256 checksum How to use checksums |
2e11b6ff94d86e216a7d596424ecd8ede406224a268a6bbe679a15da0c3b1f4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / mldashboard-1.4.5-py3-none-any.whl
| Download URL | mldashboard-1.4.5-py3-none-any.whl |
|---|---|
| Size | 77.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2afbb86d2db2bfc77813203db74bf5794137475bae0febb7a6a245ea88a313ff
|
|
BLAKE2b-256 checksum How to use checksums |
9a11986c508344f40e038014a632691313837e5f8ddfbf59850d4f14372a667a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for MLDashboard 1.4.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.