[英]"unsupported operand type(s) for ** or pow() : ' function' and 'int' "
I am trying to solve coupled ODEs .我正在尝试解决耦合 ODE 。 It contains a function raised to power 2.
它包含一个 2 次方的函数。
The following errors appears:出现以下错误:
"unsupported operand type(s) for ** or pow() : ' function' and 'int' "
The function is:功能是:
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
I think the problem is with function power.我认为问题出在功能上。 What is the right way to write a function having some integer power?
编写具有整数幂的函数的正确方法是什么?
Any suggestion or help would be appreciated.任何建议或帮助将不胜感激。
The problem is that you are trying to get power of function psy_trial1
instead of value returned by that function, to fix that you have to call that function.问题是您试图获得函数
psy_trial1
而不是该函数返回的值,以解决您必须调用该函数的问题。 Another bug that I have found is that at the end of return statement in psy1
function you are trying to subtract function psy_trial2
.我发现的另一个错误是,在
psy1
函数的 return 语句末尾,您试图减去函数psy_trial2
。 All fixes are here:所有修复都在这里:
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.