我在python中使用keras训练了一个模型,并尝试将其与matlab代码集成。
在matlab中,我通过以下方式调用python函数:res = py.mymod.myfun();
在我的python模块中,有一个来自keras的导入:
^{pr2}$
matlab中的误差为:Error using __init__> (line 65)
Python Error: AttributeError: 'NoneType' object has no attribute 'write'
Error in __init__> (line 2)
from . import backend
Error in mymod> (line 3)
import keras.models
Error in _call_with_frames_removed (line 222)
Error in exec_module (line 665)
Error in _exec (line 626)
Error in __init__>reload (line 166)
_bootstrap._exec(spec, module)
我通过以下方式验证mymod和keras都在python路径中:P = py.sys.path;
if count(P,modulePath) == 0
insert(P,int32(0),modulePath);
end
if count(P,kerasPath) == 0
insert(P,int32(0),kerasPath);
end
这个错误的原因是什么?
去掉keras的输入后,显然错误消失了。在