Tensorflow partial_run() “Must run 'setup' before performing partial runs!” despite being set up

后端 未结 2 2066
清歌不尽
清歌不尽 2021-01-24 20:29

I am building a proof-of-concept around running sub-graphs without recomputing, using tensorflow\'s partial_run() methods.

Currently I have a simple little python script

2条回答
  •  鱼传尺愫
    2021-01-24 20:42

    The error message is quite explicit: You must run the setup before (every) partial run. I think this is the reference.
    Additionally your ilist list of dicts only works for 2 runs. In the third run you only feed a value for a - this won't work. Here is a sample loop that works for me:

    ilist = [{a: 1, b: 1}, {a: 2, b: 2}, {a: 1, b: 1}, {a: 1, b: 3}]
    
    with tf.Session() as sess:
        for i, fd in enumerate(ilist):
            hdle = sess.partial_run_setup([y], [a, b])
            y_r = sess.partial_run(hdle, y, feed_dict=fd)
    
            eout = fd[a] * fd[b] + 1
            print("got {}, expected {}".format(y_r, eout))
    

提交回复
热议问题