Python 为什么重塑适用于我的列车数据,但不适用于测试数据?

Python 为什么重塑适用于我的列车数据,但不适用于测试数据?,python,reshape,Python,Reshape,这里我使用的是Fahion mnist数据集。它已经分为测试和训练。我希望每个img都是28x28x3的形状 X_train shape: (60000, 784) X_test shape: (10000, 784) # Reshaping X_train = X_train.values.reshape(-1,28,28,3) print("X_train shape: ",X_train.shape) **output:** (20000, 28, 28

这里我使用的是Fahion mnist数据集。它已经分为测试和训练。我希望每个img都是28x28x3的形状

X_train shape:  (60000, 784)

X_test shape:  (10000, 784)

# Reshaping
X_train = X_train.values.reshape(-1,28,28,3) 

print("X_train shape: ",X_train.shape) 

**output:** (20000, 28, 28, 3)
工作正常,但是

X_test = X_test.values.reshape(-1,28,28,3)
print("X_test shape: ",X_test.shape)

ValueError                                Traceback (most recent call last)
<ipython-input-110-9f1d9f52d152> in <module>()
1 X_test = X_test.values.reshape(-1,28,28,3)
2 print("X_test shape: ",X_test.shape)

 **ValueError: cannot reshape array of size 7840000 into shape (28,28,3)**
X_测试=X_测试值。重塑(-1,28,28,3)
打印(“X_测试形状:”,X_测试形状)
ValueError回溯(最近一次调用上次)
在()
1 X_测试=X_测试值。重塑(-1,28,28,3)
2打印(“X_测试形状:”,X_测试形状)

**ValueError:无法将大小为7840000的数组重塑为形状(28,28,3)**
请帮帮我

我正在关注这一点,但我已经删除了灰度部分。

这是否回答了您的问题?不,作为一个元组,它给出了类似的错误值错误:无法将大小为7840000的数组重塑为形状(3,28,28)数组中的元素总数是3 x 28 x 28的倍数吗?原始形状是:x_测试形状:(10000,784)