我试图将一个CNN模型拟合到一些输入数据df上,其中df的形状是(921 x 10170
)。
我的代码如下:
from numpy import *X = df.iloc[:,0:10165] X = X.to_numpy() X = reshape([X.shape[0], X.shape[1], 1])X_1 = X[:,0:10080,:] X_2 = X_train[:,10080:10165,:].reshape(921,85) Y = df.iloc[:,10168:10170]
并遇到了错误:
TypeError Traceback (most recent call last) in () 17 X = df.iloc[:,0:10165] 18 X = X.to_numpy()
—> 19 X = reshape([X.shape[0], X.shape[1], 1]) 20 X_train_1 = X[:,0:10080,:] 21 X_train_2 = X_train[:,10080:10165,:].reshape(921,85)<array_function internals> in reshape(*args, **kwargs)
TypeError: _reshape_dispatcher() missing 1 required positional argument: ‘newshape’
我尝试了几种方法,但都没有奏效。这里的问题是什么?谢谢
回答:
你忘记提到你在这里要重塑什么:
X = reshape([X.shape[0], X.shape[1], 1])
你需要将其更改为:
X = X.reshape((X.shape[0], X.shape[1], 1))
这样就能解决你的问题