tfdeploy icon indicating copy to clipboard operation
tfdeploy copied to clipboard

Only save once?

Open WardBeullens opened this issue 7 years ago • 2 comments

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 avatar Jun 15 '17 19:06 WardBeullens

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 avatar Jun 15 '17 19:06 WardBeullens

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

WardBeullens avatar Jun 16 '17 20:06 WardBeullens