【问题标题】:TypeError: can't pickle _thread.RLock objects LSTMTypeError:无法腌制_thread.RLock对象LSTM
【发布时间】:2021-09-01 11:16:12
【问题描述】:

当我试图保存我的模型时,它发生了。如果您能给我一些帮助,我将不胜感激,谢谢!我已经阅读了 StackOverflow 或 GitHub 问题中的一些问题,但找不到解决方案。


# add first layer with dropout

regressor.add(LSTM(units=50, return_sequences=True, input_shape=(X_train.shape[1],1)))
regressor.add(Dropout(0.2))

# add second layer

regressor.add(LSTM(units=50, return_sequences=True))
regressor.add(Dropout(0.2))

# add third layer

regressor.add(LSTM(units=50, return_sequences=True))
regressor.add(Dropout(0.2))

# add fourth layer

regressor.add(LSTM(units=50))
regressor.add(Dropout(0.2))

# the output layer

regressor.add(Dense(units=1))

# compiling the LSTM RNN network

regressor.compile(optimizer='rmsprop', loss='mean_squared_error')

# fit to the training set

regressor.fit(X_train, y_train, epochs=5, batch_size=32)

import pickle
filename = 'C:/Users/indore/Desktop/model.sav'
pickle.dump(regressor, open(filename, 'wb')) 

【问题讨论】:

    标签: python tensorflow keras lstm


    【解决方案1】:

    您不必使用pickle 来保存您的模型。使用内置方法regressor.save('model.h5')

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-03
      • 1970-01-01
      • 2018-09-18
      • 1970-01-01
      • 2020-12-31
      • 2017-10-23
      • 2019-03-12
      相关资源
      最近更新 更多