tensorflow 注意命名

来源:互联网 发布:剑指offer java版 编辑:程序博客网 时间:2024/09/21 08:17

这个报错不是数据feed的问题,而是等号左边的g_loss经过一次运算后得到了数值结果,覆盖了原来的g_loss操作,tf处理不了这种命名冲突,所以给变量用名字要注意啊

g_loss=0.01*gen_s_loss+g_c_loss
本身是一个操作。

循环执行一次后就报错

g_loss = sess.run(g_loss, feed_dict={in_: batch_con,s_img: batch_fake})
TypeError: Fetch argument 0.30283719 has invalid type <type 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)


参考:https://stackoverflow.com/questions/38306330/tensorflow-typeerror-on-session-run-arguments-output/  


还有就是不同的scope之间的命名,要利用好,这在BP传播的时候很重要,另外,一定要注意tf.variable 与tf.get_variable的差异,不要让这个折磨到吐血

原创粉丝点击