Created
July 6, 2019 14:01
-
-
Save jamesonthecrow/4fb9fd8d4b0b6bf3ca829324df2be7c1 to your computer and use it in GitHub Desktop.
Mobile machine learning made easy with the Fritz CLI. https://fritz.ai
This file contains hidden or 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 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