OpenCV 3.0 Can#39;t load neural network(OpenCV 3.0 无法加载神经网络)
问题描述
我需要在我的 OpenCV(3.0 版)项目中使用神经网络.我已经创建并训练了神经网络并且它可以工作,但是如果我想从 YML 文件加载神经网络,它不会预测.
I need to use a neural network in my OpenCV (version 3.0) project. I've created and trained neural network and it works, but if I want to load neural network from YML file, it doesn't predict.
这是我创建、训练和保存我的神经网络的代码:
This is a code where I creat, train and save my neural network:
但是下一次,如果我想从 YML 文件中加载它:
But next time, if I want to load it from YML file:
我得到输出:
[-1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND]
[-1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND]
[-1.#IND, 1.0263158, 1.0263158, 1.0263158, 1.0263158]
[-1.#IND, 1.0263158, 1.0263158, 1.0263158, 1.0263158]
[1.0263158, 1.0263158, 1.0263158, 1.0263158, 1.0263158]
[1.0263158, 1.0263158, 1.0263158, 1.0263158, 1.0263158]
[-1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND]
[-1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND]
这一行导致我收到错误:
This line cause that I get an error:
OpenCV 错误:未指明的错误(节点既不是地图也不是空集合on) 在 cvGetFileNodeByName,文件 C:uildsmaster_PackSlave-win64-vc12-sharedopencvmodulescoresrcpersistence.cpp,第 739 行
OpenCV Error: Unspecified error (The node is neither a map nor an empty collecti on) in cvGetFileNodeByName, file C:uildsmaster_PackSlave-win64-vc12-sharedop encvmodulescoresrcpersistence.cpp, line 739
我做错了什么?问题出在哪里?
What am I doing wrong? Where is the problem?
推荐答案
你可以使用 save
和 load
,或者 write
和 >阅读
,但你不应该把它们混在一起.
You can use save
and load
, or write
and read
, but you shouldn't mix them.
所以你要么需要做:
或:
这篇关于OpenCV 3.0 无法加载神经网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!