我正在尝试解决耦合ODE。它包含一个加电的功能2。出现以下错误:
"unsupported operand type(s) for ** or pow() : ' function' and 'int' "
函数是:
def psy_trial1(x,params,psy0=0):
return x*(neural_neural(params,x)
def psy_trial2(x,params, psy0=0):
return 1+x*neural_network(params,x)
def psy1(x, psy_trial1):
return A(x)+B(x)*(psy_trial1)**2-psy_trial2
我的问题是函数幂。编写具有某些整数幂的函数的正确方法是什么?
问题是您试图获取功能psy_trial1
的功能,而不是该功能返回的值,以解决必须调用该功能的问题。我发现的另一个错误是,在psy1
函数的return语句末尾,您试图减去函数psy_trial2
。所有修复程序都在这里:
def psy_trial1(x,params,psy0=0):
return x*(neural_neural(params,x)
def psy_trial2(x,params, psy0=0):
return 1+x*neural_network(params,x)
def psy1(x, psy_trial1):
return A(x)+B(x)*(psy_trial1())**2-psy_trial2()