Skip to content
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

convert to tf2 and tensorflow-probability #15

Closed
kaczmarj opened this issue Nov 5, 2019 · 1 comment
Closed

convert to tf2 and tensorflow-probability #15

kaczmarj opened this issue Nov 5, 2019 · 1 comment

Comments

@kaczmarj
Copy link
Member

kaczmarj commented Nov 5, 2019

the kwyk models should be converted to tensorflow 2 and tensorflow-probability. this will make transfer learning / hacking easier for more users.

instructions to extract the pre-trained weights from saved models

this works with tensorflow 1.13.1 and uses the saved models in https://github.com/patrick-mcclure/nobrainer.

the spike and slab model uses variables p in concrete dropout, whereas the other two models do not.

import numpy as np
import tensorflow as tf

# Load saved model.
export_dir = 'saved_models/all_50_bvwn_multi_prior/1556816070/'
predictor = tf.contrib.predictor.from_saved_model(export_dir)
# Get pre-trained weights.
ps = predictor.session.run(predictor.graph.get_collection('ps'))
ms = predictor.session.run(predictor.graph.get_collection('ms'))
sigmas = predictor.session.run(predictor.graph.get_collection('sigmas'))
# Save to file.
np.savez_compressed('spike-slab.npz', ms=ms, sigmas=sigmas, ps=ps)

related to neuronets/trained-models#3

@kaczmarj
Copy link
Member Author

closed by neuronets/nobrainer#80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant