TimeDistributed Layer 如何在收到 TimeDistributed 时定义 input_shape: (None, 1)

TimeDistributed Layer how to define input_shape when TimeDistributed received: (None, 1)

挑战

当 TimeDistributed 收到时,如何定义 TimeDistributed 层 input_shape:(None, 1)。接收的读数是多少(None, 1)?

基本代码

n_features = 1
n_seq = 2
n_steps = 2
X = X.reshape((X.shape[0], n_seq, n_steps, n_features))

model.add(TimeDistributed(Conv1D(64, 1, activation='relu'), input_shape=(n_seq, n_steps, n_features)))

输入形状错误

--> 175           '`TimeDistributed` Layer should be passed an `input_shape ` '
    176           f'with at least 3 dimensions, received: {input_shape}')
    177     # Don't enforce the batch or time dimension.

ValueError: `TimeDistributed` Layer should be passed an `input_shape ` with at least 3 dimensions, received: (None, 1)

进口

from keras.models import Sequential
from keras.layers import LSTM
from keras.layers import Dense
from keras.layers import Flatten
from keras.layers import TimeDistributed
from keras.layers.convolutional import Conv1D
from keras.layers.convolutional import MaxPooling1D

参考代码 此代码来自RNN上的在线示例代码。

使用此定义求解形状,在输入形状参数上有形状批次:

input_shape=(None, n_steps, n_features))