2016-12-05 153 views
0

我已經訓練了一個模型並將其保存。我可以加載它,並且可以訪問我想要的變量,但是我無法打印操作變量所產生的值。下面是一個簡單的例子:Tensorflow張量的打印值

def main(argv=None): 
    model = VAE(args) 
    sess_saver = tf.train.Saver() 
    sess = tf.Session() 
    init = tf.initialize_all_variables() 
    sess.run(init) 
    sess_saver.restore(sess, "model.ckpt") 

    #Getting the tf.Variable I want 
    d1 = tf.get_collection(tf.GraphKeys.VARIABLES scope='decoder')[0] 

    #Manipulating the variable 
    res1 = tf.mul(d1, 2) 

    #Printing the result - THIS IS WHERE ERRORS HAPPEN 

    print(res1) #Aborted 
    sess.run(res1) #Aborted 
    res1.eval(session=sess) #Aborted 

我得到的錯誤是:

F tensorflow/core/kernels/strided_slice_op.cc:316] Check failed: tmp.CopyFrom(input.Slice(begin[0], end[0]), final_shape) 
Aborted (core dumped) 

我如何打印操作,實際值在這種情況下應該是可變倍2的值?

+0

正如我評論你的[其他問題](http://stackoverflow.com/q/40963017/3574081),這似乎是一個錯誤。我們正在研究它,並希望儘快解決。 – mrry

+0

你可以試用最新的RC版本的TensorFlow嗎?我相信這個bug在一個月前已經修復。 – aselle

回答

0

此問題引用了2016年底修復的錯誤。答案:升級到任何版本的TensorFlow後 - 1.1或更高版本應該是安全的。