Quantcast
Channel: Active questions tagged feed-forward+tensorflow+machine-learning - Stack Overflow
Viewing all articles
Browse latest Browse all 7

You must feed a value for placeholder tensor with dtype float and shape [3,3]

$
0
0

I am writing a feed forward neural network, the goal is to be trained and predict the output of my the dataset. I am using scalar input/output. I receive an error (You must feed a value for placeholder tensor 'Placeholder_48' with dtype float and shape [3,3]).My is as below :

import pandas as pdimport tensorflow.compat.v1 as tftf.disable_v2_behavior() #importing the data and selecting the rowsdata = pd.read_csv('DATA.CSV')x_data = data.iloc[:,3:6].valuesy_data = data.iloc[:,0:3].values#hyperparametersn_input = 3n_hidden = 10n_output = 3learning_rate = 0.1epochs = 10000x_data = tf.placeholder(tf.float32, shape=[3,3])y_data = tf.placeholder(tf.float32, shape=[None])#weightsW1 = tf.Variable(tf.random_uniform([n_input, n_hidden], -1.0, 1.0))W2 = tf.Variable(tf.random_uniform([n_hidden, n_output], -1.0, 1.0))#biasb1 = tf.Variable(tf.zeros([n_hidden]), name="Bias1")b2 = tf.Variable(tf.zeros([n_output]), name="Bias2")L2 = tf.sigmoid(tf.matmul(x_data, W1) + b1)hy = tf.sigmoid(tf.matmul(L2, W2) + b2)cost = tf.reduce_mean(-y_data*tf.log(hy) - (1-(y_data))*tf.log(1-hy))optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)#tf.Session()sess =tf.InteractiveSession() sess.run(tf.global_variables_initializer())#trainfor step in range(epochs):    sess.run(optimizer, feed_dict={x_data: x_data.eval(), y_data: y_data.eval()})    if step % 1000 == 0:            print (sess.run(cost, feed_dict={x_data, y_data}))    answer =  tf.equal(tf.floor(hy + 0.5), y_data)    accuracy = tf.reduce_mean(tf.cast(answer, "float"))    print (sess.run(hy), feed_dict={x_data, y_data})    print ("accuracy: ", accuracy.eval({x_data, y_data}))

Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>