Skip to main content

Plugin to allow you to easily add Simvue tracking and monitoring to the training of Tensorflow ML models.

Project description

Simvue Plugins - TensorFlow


Simvue

This plugin allows you to easily add Simvue tracking and monitoring functionality to the training and testing of ML models built using TensorFlow.

WebsiteDocumentation

Implementation

This package provides a custom TensorVue callback, which inherits from TensorFlow's Callback class. This will do the following when training, testing or validating a model:

  • Uploads the Python script creating the model as a Code Artifact
  • Uploads the model config as an Input Artifact
  • Uploads parameters about the model as Metadata
  • Uploads the Training Accuracy and Loss after each batch to an Epoch runUploads the Training and Validation Accuracy and Loss after each Epoch to the Simulation run
  • Uploads model checkpoints after each Epoch to the corresponding Epoch run as Output Artifacts(if enabled by the user)
  • Uploads the final model to the Simulation run as an Output Artifact

Installation

To install and use this plugin, first create a virtual environment:

python -m venv venv

Then activate it:

source venv/bin/activate

And then use pip to install this module:

pip install simvue-tensorflow

Configuration

The service URL and token can be defined as environment variables:

export SIMVUE_URL=...
export SIMVUE_TOKEN=...

or a file simvue.toml can be created containing:

[server]
url = "..."
token = "..."

The exact contents of both of the above options can be obtained directly by clicking the Create new run button on the web UI. Note that the environment variables have preference over the config file.

Usage example

import tensorflow as tf
from tensorflow import keras
import numpy
import matplotlib.pyplot as plt

# Firstly we import our Tensorflow integration:
import simvue_tensorflow.plugin as sv_tf

# Load the training and test data
(img_train, label_train), (img_test, label_test) = keras.datasets.fashion_mnist.load_data()

# Normalize pixel values between 0 and 1
img_train = img_train.astype('float32') / 255.0
img_test = img_test.astype('float32') / 255.0

# Create a basic model
model = keras.Sequential()

model.add(keras.layers.Flatten(input_shape=(28, 28)))
model.add(keras.layers.Dense(32, activation='relu'))
model.add(keras.layers.Dense(10))

model.compile(optimizer=keras.optimizers.Adam(learning_rate=0.01),
            loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
            metrics=['accuracy'])

# At the most basic level, all we need to do is initialize our callback, providing a run name
tensorvue = sv_tf.TensorVue("recognising_clothes_basic")

# Train the model.
model.fit(
    img_train,
    label_train,
    epochs=5,
    validation_split=0.2,
    # Add the tensorvue class as a callback
    callbacks=[tensorvue,]
)

# That's it! Check your Simvue dashboard and you should see:
#    - A 'simulation' run, which summarises the overall training performance
#    - A number of 'epoch' runs, which show the training performed in each epoch

# You can also use the TensorVue callback to record results from model.evaluate
# Above we do it all in one step during the fitting, but you can also do it afterwards:
results = model.evaluate(
    img_test,
    label_test,
    # Add the tensorvue class as a callback
    callbacks=[tensorvue,]
)

License

Released under the terms of the Apache 2 license.

Citation

To reference Simvue, please use the information outlined in this citation file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simvue_tensorflow-1.0.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simvue_tensorflow-1.0.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file simvue_tensorflow-1.0.0.tar.gz.

File metadata

  • Download URL: simvue_tensorflow-1.0.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for simvue_tensorflow-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c40b5756c6063e340b56e02687a64d64f3a2d748fce7ea58449de9a58f05d2f5
MD5 0d90e8155c22fe2e74c978da7fab6e96
BLAKE2b-256 4d45cf3dd781f52c4747b8d6ac578103b72789a48e9fbd5f047ee0e83eb42e71

See more details on using hashes here.

Provenance

The following attestation bundles were made for simvue_tensorflow-1.0.0.tar.gz:

Publisher: deploy.yaml on simvue-io/plugins-tensorflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simvue_tensorflow-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simvue_tensorflow-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43df9d1c27a2f802a22f9b9f6c5526749a0323d238ee0095a811141e8f59a5c4
MD5 80da05ab5eb7e134700bb9eea33b8af6
BLAKE2b-256 5c566e2966f0f04bd860d3505d1cbc7031de31568d0f01dfbaa953d5c172bc23

See more details on using hashes here.

Provenance

The following attestation bundles were made for simvue_tensorflow-1.0.0-py3-none-any.whl:

Publisher: deploy.yaml on simvue-io/plugins-tensorflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page