TypeError:无法腌制NotImplementedType对象(在keras中,python) [英] TypeError: can't pickle NotImplementedType objects (in keras, python)

查看:190
本文介绍了TypeError:无法腌制NotImplementedType对象(在keras中,python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Keras进行深入研究. 但是,在学习后存储模型的过程中发生了以下错误.

I was doing deep run using Keras. However, the following error occurred in the process of storing the model after learning.

TypeError:无法腌制NotImplementedType对象

TypeError: can't pickle NotImplementedType objects

当我在另一个目录中运行相同的代码时,我没问题.

I had no problem when I ran the same code in another directory.

下面的代码是导致错误的代码部分.

The code below is the portion of the code that is causing the error.

.... 

model.add(Dense(2, activation='relu'))

model.add(Dense(1, activation='sigmoid'))

model = multi_gpu_model(model, gpus=4)

model.compile(loss='binary_crossentropy', optimizer = 'adam', metrics = ['accuracy'])

model.fit(x_train,y_train,epochs = 3, batch_size =500)


scores = model.evaluate(x_test,y_test)

#print("%s:.2f%%"%(model.metrics_names[1], scores[1]*100))

model.save('/disk3/seaice/seaice_keras_model2.h5')

泡菜的类型错误是否出现在喀拉拉邦内部的储藏方法中?

Is the type error of pickle appearing in the storage method inside the keras?

它也是相同的环境,但是我不知道为什么它在不同目录中的工作方式不同.

It's also the same environment, but I don't know why it works differently in different directories.

如果能为我提供解决此问题的方法,我将不胜感激.

I'd appreciate it if you could provide me with a solution to this problem.

推荐答案

保存多GPU模型时,Keras文档建议您调用 base save(fname)或save_weights(fname)方法. >而不是multi_gpu_model的模型(请参见页面底部的此处).

When saving a multi-gpu model, the Keras documentation recommends that you call the save(fname) or save_weights(fname) methods of the base model rather than those of the multi_gpu_model (see here, at the very bottom of the page).

我会将您的multi_gpu_model分配给新变量,而不是重新分配model.这样一来,您就可以轻松参考基本模型,以节省重量.

I would assign your multi_gpu_model to a new variable rather than reassigning model. That way you'll have an easy reference to your base model that you can use to save weights.

这篇关于TypeError:无法腌制NotImplementedType对象(在keras中,python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆