【发布时间】:2018-01-16 07:03:00
【问题描述】:
我像这样使用一维卷积。
X_train[:, None].shape
X_train_t = X_train[:, None]
X_test_t = X_test[:, None]
K.clear_session()
model = Sequential()
model.add(Conv1D(39, 1, activation='relu', input_shape=(1,12)))
model.compile(loss='mean_squared_error', optimizer='adam' )
model.summary()
model.fit(X_train_t, y_train, epochs=200, batch_size=1, verbose=1)
y_pred = model.predict(X_test)
显示这样的错误
ValueError: Error when checking target: expected conv1d_1 to have 3 dimensions, but got array with shape (39, 1)
我使用此代码打印形状 print(X_train.shape) 它显示。
(39, 12)
如果我将 input_shape 模型更改为 1,1 。
model.add(Conv1D(39, 1, activation='relu', input_shape=(1,1)))
显示错误。
ValueError: Error when checking input: expected conv1d_1_input to have shape (None, 1, 1) but got array with shape (39, 1, 12)
如何使用卷积一维?
【问题讨论】:
标签: tensorflow deep-learning keras convolution