Matlab编译的python包中的索引错误

所以我在matlab中编写了一个函数,该函数为保存在“网络”中的多个神经网络提供了六个输入,该神经网络是一个单元格数组,并返回一个向量,每个网络包含一个结果:

function e = network_evaluation(s0,s1,s2,s3,s4,s5)
    var = load("Network_single_output(6-2-1).mat","nets");
    in = [s0,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 <module>
    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”替换了原来的文件路径)。 我已经尝试使用 长度(n)-1 但这没用。有谁知道这个问题可能是什么? 提前致谢!

yiliang123 回答:Matlab编译的python包中的索引错误

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2975154.html

大家都在问