TypeError: The value of a feed cannot be a tf.Tensor object.几种情况

1、变量相同

for i in range(config.training_epochs):
        for start, end in zip(range(0, config.train_count, config.batch_size),
                              range(config.batch_size, config.train_count + 1, config.batch_size)):

            _,c = sess.run([optimizer,cost], feed_dict={X: X[start:end],
                                             Y: y_[start:end]})

修改

 _,c = sess.run([optimizer,cost], feed_dict={X: train_X[start:end],
                                             Y: y_[start:end]})
            print("traing iter: {},".format(i))

 

 _,cost = sess.run([optimizer,cost], feed_dict={X: train_X[start:end],
                                             Y: y_[start:end]})
            print("traing iter: {},".format(i))

 

修改:

 _,c = sess.run([optimizer,cost], feed_dict={X: train_X[start:end],
                                             Y: y_[start:end]})
            print("traing iter: {},".format(i))

 

还有一种是输入变量不对称,可以使用numpy中np.reshape()函数来修改

你可能感兴趣的:(Python)