解决在django中应用keras模型时出现的ValueError("Tensor %s is not an element of this graph." % obj)问题
2018-04-26 21:03
661 查看
用keras训练好模型,再在django初始化加载模型,这个过程没有问题,但是在调用到模型执行model.predict()的时候就报错:
raise ValueError("Tensor %s is not an element of this graph." % obj) ValueError: Tensor Tensor("dense_2/Softmax:0", shape=(?, 2), dtype=float32) is not an element of this graph.
解决方法:
在django中加载模型后,先执行一次model.predict()操作,之后的调用就不会出问题了
model = load_model(filepath=model_path) y = model.predict(x)
参考:https://zhuanlan.zhihu.com/p/27101000
相关文章推荐
- ValueError: Tensor Tensor("mrcnn_detection/PyFunc:0", dtype=float32) is not an element of this graph
- "this class is not key value coding-compliant for the key ..."问题的解决(转)
- "this class is not key value coding-compliant for the key ..."问题的解决
- MPI编译C++程序出现#error "SEEK_SET is #defined but must not be for the C++ binding of MPI" 的解决方法
- "this class is not key value coding-compliant for the key ..."问题的解决
- iOS "this class is not key value coding-compliant for the key ..."问题的解决
- "this class is not key value coding-compliant for the key ..."问题的解决(转)
- "this class is not key value coding-compliant for the key ..."问题的解决
- MPI编译C++程序出现#error "SEEK_SET is #defined but must not be for the C++ binding of MPI" 的解决方法
- "this class is not key value coding-compliant for the key ..."问题的解决
- 问题解决:javax.servlet.jsp.el.ELException: The "." operator was supplied with an index value of type "java.lang.String" to be applie
- 关于 "Uncaught TypeError: Property 'submit' of object #<HTMLFormElement> is not a function" 的解决方案
- “this._postbackSettings.async is null or not an object”问题的解决
- 解决 apache error 指定网络名不再可用 "an unknown filter was not added: DEFLATE"的问题
- keil(MDK)中出现error: #513: a value of type "int" cannot be assigned to an entity of type "char *",即函数返
- 解决调用context.Session["NAME"]时总出现Object reference not set to an instance of an object.异常的方法
- mysql连接linux系统提示“登录出现1130 is not allowed to connect to this MySql server”问题,解决方法
- mysql连接linux系统提示“登录出现1130 is not allowed to connect to this MySql server”问题,解决方法
- ERROR spi.SqlExceptionHelper : 'Infinity' is not a valid numeric or approximate numeric value 问题解决
- Error 47 "xxxxxxx"is an invalid value for the "InputManifest" parameter of the "GenerateApplicationM