ValueError:无法调整此数组的大小:它不拥有其数据
from keras.datasets import cifar10
import numpy as np
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
X_train1 = X_train.copy().ravel()
y_train1 = y_train.copy().ravel()
X_train2 = X_train1.resize(64*64*500)
y_train2 = y_train1.resize(64*64*500)
X_train = X_train2.resize(64*64*500).reshape(64, 64, 1)
y_train = y_train2.resize(64*64*500).reshape(64, 64, 1)
为什么在显式复制数据后出现此错误?如何解决这个问题?
最佳答案
使用numpy中的reshape,将行更改为
X_train2 = np.resize(X_train1, 64*64*500)
y_train2 = np.resize(y_train1, 64*64*500)
关于python-3.x - 值错误: cannot resize this array: it does not own its data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53686986/