feed_dict在Tensorflow中不起作用

时间:2017-09-13 12:08:00

标签: tensorflow conv-neural-network training-data

我在使用tensorflow时遇到了问题。

def train_network(file_folder, file_list, hm_epoch, batch_size):
  x = tf.placeholder(tf.float32, [1, 5, 200, 300, 5])
  y1 = tf.placeholder(tf.int32)

  class_set = []
  score_set = []

  class_logit, temp = convolutional_neural_network(x)
  class_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=class_logit, labels=y1))
  optimizer1 = tf.train.RMSPropOptimizer(learning_rate=1e-6).minimize(class_loss)

  sess = tf.Session()
  sess.run(tf.global_variables_initializer())

  for epoch in range(hm_epoch):

    epoch_loss = 0

    for file_name in file_list:

      _flie = file_folder + '/' + file_name
      X_total, Y1_class, _ = read_as_batch(_file)
      n_batch = int(X_total.shape[0] / batch_size)

      for i in range(n_batch):

        batch_X = get_batch_piece(X_total, batch_size, i)
        Y1_class = get_batch_piece(Y1_class, batch_size, i)

        _, a, b, c = sess.run([optimizer1, class_loss, tf.gather(class_logit, 0), tf.gather(temp, 0)], feed_dict={x:batch_X, y1:Y1_class_})

我的图像数据在“sess.run”之前成功打印。 但是,在函数convolutional_neural_network(x)中,输入仅填充0.在我看来,feed_dict根本不起作用。 有没有人可以解决这个问题或者有相同的经历?

0 个答案:

没有答案