-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customizing Base Models #125
Comments
I'm going to flesh out this approach a bit better to show how you customize a base model, then version control it here in the repository for others to use. Below is untested code, you may need to tweak it, but its correct in spirit to how Minutes should behave. import os
from keras.models import Sequential
from minutes.base import BaseModel
from minutes import Speaker
class MyBaseMinutesModel(BaseModel):
"""Subclass the BaseModel and override the fit method
(thats all you need to do).
"""
def fit(self, **kwargs):
X_train, X_test, y_train, y_test = self._generate_training_data()
# Design and train your model, then assign it to self.model.
self.model = Sequential([
# ...
])
self.model.compile()
self.model.fit()
# Define hyperparameters (there is one at the moment and it determines
# the type of data generated by `_generate_training_data`.
new_base = MyBaseMinutesModel(
'human-readable-name',
ms_per_observation=1000
)
# Add many speakers.
for folder in os.listdir('/path/to/speakers/'):
# Assuming folder is speakers name.
s = Speaker(folder)
# Assuming folder contains audio for speaker.
s.add_audio('/path/to/speakers/' + folder)
new_base.add_speaker(s)
new_base.fit(verbose=2) # Takes a while :)
new_base.save() Note that git checkout -b new-model-type
git add minutes/models/*
git commit -m "My new model got 99%!"
git push origin HEAD We have work to do to standardize the naming of the output models. Currently it uses the name specified by the user, but it should have some other features to make it unique/informative/serialized. |
Customizing a
BaseModel
is pretty simple at the moment. Something like:I don't think we need to make this anymore convenient for the user, but some documentation for this should exist in the README.
The text was updated successfully, but these errors were encountered: