0
votes

Now iterate over our dataset n_epoch times for iteration in range(epoch): print("Iteration no: {} ".format(iteration))

previous_batch=0
# Do our mini batches:
for i in range(no_itr_per_epoch):
    current_batch=previous_batch+batch_size
    x_input=X_train[previous_batch:current_batch]
    x_images=np.reshape(x_input,[batch_size,50,50,3])

    y_input=Y_train[previous_batch:current_batch]
    y_label=np.reshape(y_input,[batch_size,2])
    previous_batch=previous_batch+batch_size

    _,loss=sess.run([train_step, cross_entropy], feed_dict={x: x_images,y_: y_label})
    if i % 100==0 :
        print ("Training loss : {}" .format(loss))



x_test_images=np.reshape(X_test[0:n_test],[n_test,50,50,3])
y_test_labels=np.reshape(Y_test[0:n_test],[n_test,2])
Accuracy_test=sess.run(accuracy,
                       feed_dict={
                    x: x_test_images ,
                    y_: y_test_labels
                  })
Accuracy_test=round(Accuracy_test*100,2)

x_val_images=np.reshape(X_val[0:n_val],[n_val,50,50,3])
y_val_labels=np.reshape(Y_val[0:n_val],[n_val,2])
Accuracy_val=sess.run(accuracy,
                       feed_dict={
                    x: x_val_images ,
                    y_: y_val_labels
                  })    
Accuracy_val=round(Accuracy_val*100,2)
print("Accuracy ::  Test_set {} % , Validation_set {} % " .format(Accuracy_test,Accuracy_val))

ValueError: cannot reshape array of size 20000 into shape (8,50,50,3)

def process_img(img):

1
The new shape should be compatible with the original shape. (8,50,50,3) leads to 60000 compared to your original size of 20000N.Moudgil

1 Answers

1
votes

8 * 50 * 50 * 3 = 60,000. Therefore the original with size 20,000 can't be resized to the new shape. What you can do is reshape it to (8, 50, 50, 1) and then broadcast, since 8 * 50 * 50 = 20,000.