Hello There I hope you guys are in good health. I am new to deep learning and havning some problem in traning my deep neural network on Cifar10 dataset. I am getting value error setting an array element with sequence I am sharing my traning function.
code
def traning_neuralNetwork(x_train,y_train):
total_epochs=10
total_loss=0
epoch_loss=0
batch_size=200
num_batch = int(np.ceil(48000/batch_size))
prediction=neural_network(x)
cost=tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=prediction,labels=y))
optimizer=tf.train.AdamOptimizer().minimize(cost)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for epoch in range (total_epochs):
total_loss=0
for _ in range (num_batch):
x_train,y_train=next_batch(batch_size,x_train,y_train)
_,epoch_loss=sess.run([optimizer,cost],feed_dict={x:x_train,y:y_train})
total_loss+=epoch_loss
print('Epoch ',epoch, " loss = ",total_loss)
print("Traning Complete!")
correct=tf.equal(tf.argmax(prediction,1),tf.argmax(y,1))
accuracy=tf.reduce_mean(tf.cast(correct,'float'))
print('accuracy',accuracy.eval({x:x_test,y :y_test}))
Error
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-53-aeb4ef85487e> in <module>()
----> 1 traning_neuralNetwork(x_train,y_train)
<ipython-input-52-432dcd8eb993> in traning_neuralNetwork(x_train, y_train)
67 for _ in range (num_batch):
68 x_train,y_train=next_batch(batch_size,x_train,y_train)
---> 69 _,epoch_loss=sess.run([optimizer,cost],feed_dict={x:x_train,y:y_train})
70 total_loss+=epoch_loss
71 print('Epoch ',epoch, " loss = ",total_loss)
/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
906 try:
907 result = self._run(None, fetches, feed_dict, options_ptr,
--> 908 run_metadata_ptr)
909 if run_metadata:
910 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1110 feed_handles[subfeed_t] = subfeed_val
1111 else:
-> 1112 np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
1113
1114 if (not is_tensor_handle_feed and
/opt/conda/lib/python3.6/site-packages/numpy/core/numeric.py in asarray(a, dtype, order)
490
491 """
--> 492 return array(a, dtype, copy=False, order=order)
493
494
ValueError: setting an array element with a sequence.