我试着用Keras(2.2.0版)和TensorFlow(1.1.0版)训练LSTM神经网络我知道有更新的TensorFlow版本,但不幸的是
I'm having some issues installing them
. 但是,我不认为我的问题与TensorFlow版本有关。
这就是我的Keras代码的样子:
[...] from keras.layers import Dense, Dropout, LeakyReLU, LSTM, Activation, Dense, Dropout, Input, Embedding
def LSTM(X,Y):
inputDimension = len(X[0])
inputSize = len(X)
# create the model
model = Sequential()
model.add(Embedding(input_length=inputDimension,input_dim=inputDimension,output_dim=256))
model.add(LSTM(100))
model.add(Dropout(0.2))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(X,Y,epochs=3,batch_size=64)
return model
每当我尝试运行它时,都会出现以下错误消息:
回溯(最近一次呼叫时间):
文件“Main.py”,第208行,lstmodel=ann.LSTM(scaleTrainingx,trainingY)
文件“ann.py”,第158行,在LSTM model.add(LSTM(100))中
TypeError:LSTM()缺少1个必需的位置参数:“Y”
我发现
this question
在StackOverflow上,但是建议的解决方案没有帮助,因为我没有使用生成器来训练我的网络。
任何帮助使这个网络运行将是非常感谢的非常感谢你。