Tensorflow summery merge error : Shape [-1,784] has negative dimensions

前端 未结 3 526
终归单人心
终归单人心 2021-01-12 04:24

I am trying to get summary of a training process of the neural net below.

import tensorflow as tf 
import numpy as n         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 05:12

    From one comment of the deleted answer, from the original poster:

    I actually build a neural net under with tf.Graph() as g. I removed the interactive session and started session as with tf.Session(g) as sess. It fixed the problem.

    The graph g was not marked as the default graph that way, thus the session (tf.InteractiveSession in the original code) would use another graph instead.

    Note that I stumbled upon here because of the same error message. In my case, I had accidentally something like this:

    input_data = tf.placeholder(tf.float32, shape=(None, 50))
    input_data = tf.tanh(input_data)
    session.run(..., feed_dict={input_data: ...})
    

    I.e. I didn't feed the placeholder. It seems that some other tensor operations can then result in this confusing error as internally an undefined dimension is represented as -1.

提交回复
热议问题