Created
February 10, 2016 08:24
-
-
Save marcromeyn/ea450dcd58cbe1bd3cad to your computer and use it in GitHub Desktop.
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
| def save_file(filepath): | |
| f = h5py.File(filepath, 'w') | |
| f.attrs['nb_documents'] = len(self.layers) | |
| for k, l in enumerate(self.layers): | |
| g = f.create_group('doc_{}'.format(k)) | |
| weights = l.get_weights() | |
| g.attrs['nb_params'] = len(weights) | |
| for n, param in enumerate(weights): | |
| param_name = 'param_{}'.format(n) | |
| param_dset = g.create_dataset(param_name, param.shape, | |
| dtype=param.dtype) | |
| param_dset[:] = param | |
| f.flush() | |
| f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment