【发布时间】:2019-12-12 18:57:09
【问题描述】:
我对 LSTM 顺序网络的输入尺寸和形状有疑问。我正在寻找正确的方法来重塑和适应这个 input_merged (?, 1, 2400, 60) 到 LSTM 输入已成功连接,但不接受来自 LSTM 网络输入的新维度。
计划
inp1 = Input(features_set3.shape)
inp2 = Input(features_set4.shape)
print(" shapeINP1 ")
print(inp1.shape)
print(" shapeINP2 ")
print(inp2.shape)
input_merged = Concatenate(axis=2)([inp1, inp2])
print(input_merged.shape)
print(" OK ")
lstm = LSTM(units=50, return_sequences=True, input_shape=input_merged.shape)(input_merged)
model = Sequential()
model.add(LSTM)
尺寸错误和输入形状的日志
b'你好,TensorFlow!' 42 使用 TensorFlow 后端。
功能集 (1200, 60)
features_set3 (1, 1200, 60) DataConversionWarning:输入 dtype int64 的数据已由 MinMaxScaler 转换为 float64。 warnings.warn(msg, DataConversionWarning)
features_set2
(1200, 60)
features_set4
(1, 1200, 60)
形状INP1
(?, 1, 1200, 60)
shapeINP2
(?, 1, 1200, 60)
(?, 1, 2400, 60)
好的 回溯(最近一次通话最后): prog10-t12.py",第 84 行,在模块中 lstm = LSTM(units=50, return_sequences=True, input_shape=input_merged.shape)(input_merged)
文件“C:\ProgramData\Anaconda3\lib\site-packages\keras\layers\recurrent.py”,第 532 行,调用中 返回超级(RNN,自我)。调用(输入,kwargs) 文件“base_layer.py”,第 414 行,调用中 self.assert_input_compatibility(输入) 文件“C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\base_layer.py”,第 311 行,在 assert_input_compatibility str(K.ndim(x)))
ValueError: Input 0 is in compatible with layer lstm_1: expected ndim=3, found ndim=4
【问题讨论】:
标签: python input keras lstm dimension