因此,我在matlab中编写了一个函数,该函数为保存在“网络”中的多个神经网络提供了六个输入,这是一个单元格数组,并返回一个向量,每个网络包含一个结果:
function e = network_evaluation(s0,s1,s2,s3,s4,s5) var = load("Network_single_output(6-2-1).mat", "nets"); in = [s0, s1, s2, s3, s4, s5]'; n = var.nets; e = zeros(1,length(n)); for i = 1:length(n) e(i) = n{i}(in); end end 然后,我习惯了Matlab编译器SDK来获取一个Python包,该包已成功安装并在Python中调用。但是,当我运行函数时,出现错误:
Warning: Class 'network' is an unknown object class or does not have a valid 'loadobj' method. Element(s) of this class in array 'nets' have been converted to structures. > In net_ev (line 2) Index exceeds the number of array elements (1). Error in net_ev (line 7) Traceback (most recent call last): File path, line 11, in result = netting.net_ev(1,2,3,4,5,6) File path, line 80, in __call__ nlhsWasSpecified, stdoutObj, stderrObj).result() File "C:\Program Files\MATLAB\R2019b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\futureresult.py", line 135, in result raise e matlab_pysdk.runtime.MatlabRuntimeError: An error occurred when evaluating the result from a function. Details: File path\net_ev.m, line 7, in net_ev Index exceeds the number of array elements (1). (我已经用“ path”替换了这里的实际文件路径)。我已经尝试使用length(n)-1,但是没有用。有谁知道这个问题可能是什么?提前致谢!
更多&回答...