2017-08-15 170 views

回答

0

到LSTM层的输入数据需要是三维的,形状为(num_samples, timesteps, num_features)

您指定给LSTM层的input_shape的形状为(timesteps, num_features)input_shape不关心样本的数量,只是关于每个样本的形状。

如果我们假设timesteps=1,你会想要做这样的事情。

arr = np.array([1, 2, 3]) 
arr.shape # (3,) 
arr = arr.reshape(arr.shape[0], 1, 1) 
arr.shape # (3, 1, 1) 

model.add(LSTM(128, input_shape=(arr.shape[1], arr.shape[2]))) 

它不会使一吨的意义上使用LSTMs与timesteps=1,但希望你的想法。