输入形状
X_train.shape
Out[29]: (90000, 9)
这是我的模特:
def cnn_1d(window_size,nb_input_series):
model = Sequential()
model.add(Conv1D(32, 9, activation='relu', input_shape=(window_size, nb_input_series)))
model.add(Conv1D(32, 9, activation='relu'))
model.add(MaxPooling1D(2))
model.add(Dropout(0.25))
model.add(Conv1D(64, 9, activation='relu'))
model.add(Conv1D(64, 9, activation='relu'))
model.add(MaxPooling1D(pool_size=2))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(50, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))
model=cnn_1d(1,X_train.shape[1])
但错误提升
ValueError: Negative dimension size caused by subtracting 9 from 1 for 'conv1d_11/convolution/Conv2D' (op: 'Conv2D') with input shapes: [?,1,1,9], [1,9,9,32].
需要:
我应该使用嵌入吗?
需要重塑吗?
提前致谢...
答案 0 :(得分:0)
Conv1D图层接受3D输入。您的X_train应该重塑为
(no_samples, steps, input_dim)
答案 1 :(得分:0)
您必须重新塑造数据
(no_of_samples/timesteps,timesteps,input_dim)