Tensorflow Sitzung.ausführen füttern dict-Mechanismus

So, ich bin der neue tensor-flow, und mein Fehler ist, dass ich die Fütterung in
invalid argument x für train_neural_network(x).

Was ich versuche zu tun, ist für 4999 Iterationen, Eingang a [1,400] - array, das sind
die bit-Werte für ein Bild. Eingangs-4999 Bilder. Ich lese die Bilder mit
scipy.io als Matrizen, Tensoren nicht.

Ich bin verwirrt darüber, wie die Platzhalter werden verwendet, und was ist generell Los mit meinem code. seit ich feed in x und y ist der Platzhalter, sollte nicht die Eingabe x zu train_neural_network(x) werden die Platzhalter-Werte?

x = tf.placeholder('float',[1,400])
y = tf.placeholder('float',[1,10])


def neural_network_model(data):

        hidden_layer1 = {'weights':tf.Variable(tf.random_normal([400,n_nodes_hl1])),
                        'biases':tf.Variable(tf.random_normal(n_nodes_hl1))}

        hidden_layer2 = {'weights':tf.Variable(tf.random_normal([n_nodes_hl1,n_nodes_hl2])),
                        'biases':tf.Variable(tf.random_normal(n_nodes_hl2))}

        hidden_layer3 = {'weights':tf.Variable(tf.random_normal([n_nodes_hl2,n_nodes_hl3])),
                        'biases':tf.Variable(tf.random_normal(n_nodes_hl3))}

        output_layer = {'weights':tf.Variable(tf.random_normal([n_nodes_hl3,n_classes])),
                        'biases':tf.Variable(tf.random_normal([n_classes]))}

        #(input * weights) + biases 

        l1 = tf.add(tf.matmul(data, hidden_layer1['weights']),hidden_layer1['biases'])
        l1 = tf.nn.relu(l1)

        l2 = tf.add(tf.matmul(l1, hidden_layer2['weights']),hidden_layer2['biases'])
        l2 = tf.nn.relu(l2)

        l3 = tf.add(tf.matmul(l2, hidden_layer3['weights']),hidden_layer3['biases'])
        l3 = tf.nn.relu(l3)

        output = tf.add(tf.matmul(l3, output_layer['weights']),output_layer['biases'])

        return output

def train_neural_network(x): 

        prediction = neural_network_model(x)
        cost = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(prediction,y))
        optimizer = tf.train.AdamOptimizer().minimize(cost)

        hm_epochs = 4999 

        with tf.Session() as sess:
            sess.run(tf.initialize_all_variables())

            for epoch in range(hm_epochs):  

                sess.run([optimizer,cost], feed_dict = {x: input_X[epoch], y: encoded_y[epoch]})
                print('Epoch',epoch,'completed out of', hm_epochs)

Den eigentlichen Fehler sieht wie folgt aus:

%run "/Users/JaeWoo/Desktop/research/tensorpractice/DeepNeural.py"

train_neural_network(x)

W tensorflow/core/framework/op_kernel.cc:940] Invalid argument: shape must be a vector of {int32,int64}, got shape []

W tensorflow/core/framework/op_kernel.cc:940] Invalid argument: shape must be a vector of {int32,int64}, got shape []
... repeated for several times 


InvalidArgumentError                      Traceback (most recent call last)

<ipython-input-86-7c7cbdae9b34> in <module>()

----> 1 train_neural_network(x)

/Users/JaeWoo/Desktop/research/tensorpractice/DeepNeural.py in 

train_neural_network(x)

     67 
     68         with tf.Session() as sess:
---> 69             sess.run(tf.initialize_all_variables())
     70 
     71             for epoch in range(hm_epochs):
können Sie dies ändern "feed_dict = {" an "feed_dict={". Ich erinnere mich nicht, wenn der Abstand zählt.
Ihr füttert ein leeres array, wie es scheint, kann u teilen, wie sind Sie generieren die input_X???

InformationsquelleAutor Djae | 2016-09-20

Schreibe einen Kommentar