【发布时间】:2019-11-20 09:22:41
【问题描述】:
#converting the lists into numpy arrays
x_train=np.array(x_train)
x_test=np.array(x_test)
y_train=np.array(y_train)
y_test=np.array(y_test)
x_train.shape,x_test.shape,y_train.shape,y_test.shape
问题从下面的代码开始
整形为 2d 以保存为 csv 格式
x_train_2d=np.reshape(x_train,(x_train.shape[0],x_train.shape[1]*x_train.shape[2]))
x_test_2d=np.reshape(x_test,(x_test.shape[0],x_test.shape[1]*x_test.shape[2]))
x_train_2d.shape,x_test_2d.shape
【问题讨论】:
-
数组的原始形状是什么?
-
也发布错误输出
-
numpy数组_train.shape,x_test.shape,y_train.shape,y_test.shape的形状是((7895, 40), (837, 40), (7895,), (837, ))
-
形成的错误是:IndexError Traceback (最近一次调用最后一次)
in () ----> 1 x_train_2d=np.reshape(x_train, (x_train.shape[0],x_train.shape[1]*x_train.shape[2])) 2 x_test_2d=np.reshape(x_test,(x_test.shape[0],x_test.shape[1]*x_test.shape [2])) 3 x_train_2d.shape,x_test_2d.shape IndexError: tuple index out of range -
输出形状应该是什么。
标签: python-3.x export-to-csv google-colaboratory