简体   繁体   English

无法将大小为 20000 的数组重塑为形状 (8,50,50,3)

[英]cannot reshape array of size 20000 into shape (8,50,50,3)

Now iterate over our dataset n_epoch times for iteration in range(epoch): print("Iteration no: {} ".format(iteration))现在迭代我们的数据集 n_epoch 次以在 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) ValueError:无法将大小为 20000 的数组重塑为形状 (8,50,50,3)

def process_img(img): def process_img(img):

8 * 50 * 50 * 3 = 60,000. 8 * 50 * 50 * 3 = 60,000。 Therefore the original with size 20,000 can't be resized to the new shape.因此,大小为 20,000 的原件无法调整为新形状。 What you can do is reshape it to (8, 50, 50, 1) and then broadcast, since 8 * 50 * 50 = 20,000.你可以做的是将它重塑为 (8, 50, 50, 1) 然后广播,因为 8 * 50 * 50 = 20,000。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ValueError:无法将大小为 30470400 的数组重塑为形状 (50,1104,104) - ValueError: cannot reshape array of size 30470400 into shape (50,1104,104) 无法将大小为 0 的数组重塑为形状 - Cannot reshape array of size 0 into shape 无法将大小为470的数组重塑为形状(20) - Cannot reshape array of size 470 into shape (20) 无法将大小为 x 的数组重塑为形状 y - Cannot reshape array of size x into shape y ValueError:无法将大小为 1 的数组重塑为形状 (1,4) - ValueError: cannot reshape array of size 1 into shape (1,4) 无法将大小为 1 的数组重塑为形状 (150,5) - Cannot reshape array of size 1 into shape (150,5) 无法将大小为 1934 的数组重塑为形状 (3,1) - cannot reshape array of size 1934 into shape (3,1) ValueError:无法将大小为 2 的数组重塑为形状 (1,4) - ValueError: cannot reshape array of size 2 into shape (1,4) ValueError:无法为张量“输入/X:0”提供形状(1、50、50、3)的值,其形状为“(?、50、50、1)” - ValueError: Cannot feed value of shape (1, 50, 50, 3) for Tensor 'input/X:0', which has shape '(?, 50, 50, 1)' ValueError:无法将输入数组从形状(50,50,3)广播到形状(50,50) - ValueError: could not broadcast input array from shape (50,50,3) into shape (50,50)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM