-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Default session for the TensorFlowModel #37
Comments
Thanks Ivan, we certainly need to improve the documentation. Would you have expected a different syntax to specify a custom session? Maybe we can make it easier to use |
Maybe there could be an optional argument for a user-defined session in the
If no session if provided, then |
I added a new page in the documentation with examples, in particular lot's of examples of the different ways to create a @ivust What you are using right now is basically Option 4. Have a look at the other options, I think Option 1, Option 2 and Option 3 are nicer. Your proposal, session = tf.Session()
restorer.restore(session, '/path/to/vgg_19.ckpt')
model = foolbox.models.TensorFlowModel(images, logits, (0, 255), session=session)
print(np.argmax(model.predictions(image)))
session.close() is basically a fifth option that's almost identical to Option 3 and therefore will not be implemented for now (I would however accept pull-requests for this, if you really want it). |
Considering this solved. @ivust let me know if I missed something. |
As I understood from the code (https://github.com/bethgelab/foolbox/blob/master/foolbox/models/tensorflow.py), the constructor of the TensorFlowModel tries to use the default session, otherwise it creates a new one, where all variables need to be reinitialised. That means that if there is a running session with initialised variables in it, then the TensorFlowModel should be created with this session being a default one:
Maybe that is obvious, but it took me some time to figure what was going on, so you guys may consider adding a note on that to the documentation :-)
The text was updated successfully, but these errors were encountered: