Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mobile machine learning made easy with the Fritz CLI. https://fritz.ai
import fritz
import fritz.train
# Fritz needs to be configured first. Calling the fritz.Configure() method will
# read the credentials we setup for the CLI earlier.
fritz.configure()
# Create the callback
# Start by defining a training configuration and storing it as metadata
metadata = {
"learning_rate": 0.001,
"batch_size": 256
}
# Specify model ids so new versions of our model get associated with the
# original checkpoing uploads from above.
model_ids = {
fritz.frameworks.KERAS: "<YOUR KERAS MODEL ID>",
fritz.frameworks.CORE_ML: "<YOUR CORE ML MODEL ID>",
fritz.frameworks.TENSORFLOW_LITE: "<YOUR TENSORFLOW LITE MODEL ID>"
}
# Specify our conversion functions so keras checkpoints
# get turned into Core ML and TFLite models each time
converters = {
fritz.frameworks.CORE_ML: convert_to_coreml,
fritz.frameworks.TENSORFLOW_LITE: convert_to_tflite
}
fritz_callback = fritz.train.FritzSnapshotCallback(
model_ids_by_framework=model_ids,
converters_by_framework=converters,
output_file_name="mnist.h5",
metadata=metadata,
period=10 # Save after every 10 epochs and at the end of training
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.