MyNN
MyNN copied to clipboard
Add support for exporting models
The current solution looks like iterating through the model parameters and np.save
ing all the weights, then np.load
ing them in a new model. We should support actually serializing a model
def save_model(self, path):
"""Path to .npz file where model parameters will be saved."""
with open(path, "wb") as f:
np.savez(f, *(x.data for x in self.parameters))
def load_model(self, path):
with open(path, "rb") as f:
for param, (name, array) in zip(self.parameters, np.load(f).items()):
param.data[:] = array