ANN模型收敛但lstm不收敛

时间:2019-07-07 01:28:44

标签: python tensorflow keras deep-learning regression

我正在尝试构建LSTM架构来预测疾病发生率(0%-100%)。

我已经建立了ANN模型,并且收敛到mse = 0.8,这对于我的情况是可以接受的。

import numpy 
numpy.random.seed(8) 
def build_dropout_model2(rate):
    model = Sequential() 
    model.add(Dense(1000, input_shape=(10,), activation="relu"))    
    model.add(Dense(500, activation="relu")) 
    model.add(Dense(1)) model.summary() 
    model.compile(loss="mean_squared_error", optimizer="adam", metrics=["mean_squared_error"]) 
    model2 = build_dropout_model2()
    return model

这是我的LSTM模型:

def lstm_model(): 
    model = Sequential() 
    model.add(LSTM(10, input_shape=(1,10), return_sequences= True))  
    model.add(Dropout(0.2)) 
    model.add(LSTM(100, return_sequences= True)) 
    model.add(LSTM(100, return_sequences= False))
    model.add(Dense(1,activation="linear"))   
    model.compile(optimizer='adam',loss='mean_squared_errorrmetrics=['mean_squared_error'])      
    return model
Lstm=lstm_model()

 newlstmhis = lstm.fit(xtrr,ytr,epochs=1000 , validation_data=(xtstt, ytst),verbose=2, shuffle=True)

我尝试了一些技巧,例如更改优化器,层节点数和丢失值,而没有任何改进,并且该模型无法收敛mse = 12.4。你们可以根据您的经验帮我一些建议。谢谢大家

0 个答案:

没有答案