Ich bekomme eine Ungenauigkeit der Formen zwischen Eingabe und der Feedhalter, obwohl ich ziemlich sicher bin, dass die Formen in beiden Fällen identisch sind. Hier ist der Code: ex3data1.mat enthält eine 5000 * 400 Matrix X.Feedformer Shape Mismatch in Tensorflow
import tensorflow as tf
import numpy as np
`import scipy.io as sio
theta1 = sio.loadmat('ex3weights.mat')['Theta1']
theta2 = sio.loadmat('ex3weights.mat')['Theta2']
x = tf.placeholder(tf.float64, shape=[1, 400])
x2 = tf.concat([[[1]] ,x], 1)
z2 = tf.matmul(x2,np.transpose(theta1))
h1 = tf.divide(1.0, (1.0 + tf.exp(-z1)))
h1= tf.concat([[[1]],h1], 1)
z2 = tf.matmul(h1, np.transpose(theta2))
max = tf.argmax(z2)
max = max+1
sess = tf.Session()
op = sio.loadmat('ex3data1.mat')['X'][1234]
op = np.reshape(op, [1, 400])
op.astype(np.float64)
m = {x:op}
sess.run(max,feed_dict=m)
ich die folgende Fehlermeldung erhalten:
InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_2' with dtype double and shape [1,400]
[[Node: Placeholder_2 = Placeholder[dtype=DT_DOUBLE, shape=[1,400], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Ich glaube nicht, dass dies dein Problem ist, aber 'op.astype (np.float64)' tut nichts. 'astype' ist keine Inplace-Operation - das könnte der Fehler sein. Die Nachricht sagt, dass der dtype sowie die Form übereinstimmen müssen. – hpaulj