你好,我想腌制我训练的模型,但是会发生此错误:TypeError:无法腌制_thread.RLock对象 你能告诉我我做错了吗。这是我的代码:
model = Sequential()
model.add(Conv2D(32, kernel_size=(2,2), input_shape=(956, 244,1), padding='same', activation='relu'))
model.add(MaxPooling2D())
model.add(Conv2D(64, kernel_size=(2,2), padding='same', activation='relu'))
model.add(MaxPooling2D())
model.add(Conv2D(128, kernel_size=(2,2), padding='same', activation='relu'))
model.add(MaxPooling2D())
model.add(Conv2D(64, kernel_size=(2,2), padding='same', activation='relu'))
model.add(MaxPooling2D())
model.add(Conv2D(32, kernel_size=(2,2), padding='same', activation='relu'))
model.add(MaxPooling2D())
model.add(Flatten())
model.add(Dense(1024, activation='relu'))
model.add(Dense(11, activation='softmax'))
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
这是我的训练方式:
history = model.fit(X_train, y_train, epochs=20, validation_split=0.3)
这就是我尝试腌制它(显示错误)的方法:
#Pickle Model
with open("model_pickle","wb") as f:
pickle.dump(model,f)
Out[]:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-23-ead702cd9e07> in <module>
1 #Pickle Model
2 with open("model_pickle","wb") as f:
----> 3 pickle.dump(model,f)
TypeError: can't pickle _thread.RLock objects
请帮助(T.T)