各位大大好,小弟是 ML 剛入門的新手,自己在嘗試建 LSTM 模型,在 model.fit() 的過程,程式跑到 epoch 1/N 就開始不會動了,不過我看 jupyter notebook 的 kernel 是一直在運行的,memory 感覺也有在變動(但是動一下就不動了),CPU 也是使用率突然升高一陣子之後就沒再動了。
不知道各位大大有沒有類似的經驗可以指點迷津><感恩~~
下方是我的 code ,請參考:
x_train = [[[0. 0.04516129 0. 0.05696203]
[0.0754717 0.03870968 0.00632911 0. ]
[0.01886792 0. 0.01898734 0.01898734]
...
[0.21383648 0.22580645 0.20253165 0.24050633]
[0.25157233 0.24516129 0.24683544 0.25316456]
[0.26415094 0.29032258 0.26582278 0.28481013]]
[[0.6163522 0.59354839 0.62025316 0.60759494]
[0.6163522 0.59354839 0.60759494 0.59493671]
[0.59748428 0.58709677 0.60126582 0.60126582]
...
[0.64779874 0.62580645 0.65189873 0.63924051]
[0.65408805 0.63225806 0.65822785 0.64556962]
[0.64779874 0.62580645 0.65189873 0.63924051]]]
y_train = [0.29746835 0.27848101 0.27848101 ... 0.64556962 0.63924051 0.64556962]
def build_model(input_length, input_dim):
d = 0.25
model = Sequential()
model.add(LSTM(30, input_shape=(input_length, input_dim), return_sequences=True))
model.add(Dropout(d))
model.add(LSTM(30,input_shape=(input_length, input_dim), return_sequences=False))
model.add(Dropout(d))
model.add(Dense(6,kernel_initializer="uniform",activation='relu'))
model.add(Dense(1,kernel_initializer="uniform",activation='linear'))
model.compile(loss='mse',optimizer='adam', metrics=['accuracy'])
return model
#建立model
model = build_model(30, 4)
train_history = model.fit( x_train, y_train, batch_size=1, epochs=5, validation_split=0.25, verbose=2, use_multiprocessing=False)
output:(卡在這邊不動)