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

Only save once? #34

Open
WardBeullens opened this issue Jun 15, 2017 · 2 comments
Open

Only save once? #34

WardBeullens opened this issue Jun 15, 2017 · 2 comments

Comments

@WardBeullens
Copy link

WardBeullens commented Jun 15, 2017

It seems that after saving a model, all subsequent saves are identical.

I made a minimal example that reproduces the problem:

import tensorflow as tf
import tfdeploy.tfdeploy as td

def pickleModel(sess,out,file_name):
    model = td.Model()
    model.add(out,sess)
    model.save(file_name)

def unpickleModel(file_name):
    model = td.Model(file_name)
    out = model.get('output')
    print("td evaluation = ",out.eval())

if __name__ == '__main__':

    counter = tf.Variable(  0.0  , name='counter' )
    out = tf.multiply(counter,1,name ='output')
    increment = tf.assign(counter,counter+1)

    sess = tf.Session()
    sess.run(tf.global_variables_initializer())

    pickleModel(sess,out,'file1')
    print('tensorflow evaluation = ',sess.run(out))
    unpickleModel('file1')

    sess.run(increment)

    pickleModel(sess,out,'file2')
    print('tensorflow evaluation = ',sess.run(out))
    unpickleModel('file2')

The ouput is :
tensorflow evaluation = 0.0
td evaluation = 0.0
tensorflow evaluation = 1.0
td evaluation = 0.0

But the last td evaluation should be equal to 1.0. What is going on?

@WardBeullens
Copy link
Author

Also, I had to add an 'out' node to the computation graph which multiplies the counter by one, because if I try to add the 'counter' variable directly to the td.Model() I got an error.

@WardBeullens WardBeullens changed the title Multiprocessing trouble Only save once? Jun 15, 2017
@WardBeullens
Copy link
Author

I don't know what is going on, but the code works as expected if I reload the td module before each save session.

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