简体   繁体   English

“不支持 ** 或 pow() 的操作数类型:'function' 和 'int'”

[英]"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.

相关问题 **或pow()不支持的操作数类型:“函数”和“整数” - unsupported operand type(s) for ** or pow(): 'function' and 'int' TypeError:**或pow()不支持的操作数类型:“函数”和“整数”概率计算器 - TypeError: unsupported operand type(s) for ** or pow(): 'function' and 'int' probability calculator **或pow()不支持的操作数类型:'Entry'和'int'? - unsupported operand type(s) for ** or pow(): 'Entry' and 'int'? **或pow()不支持的操作数类型:'method'和'int' - unsupported operand type(s) for ** or pow(): 'method' and 'int' ** 或 pow() 不支持的操作数类型:“list”和“int”错误 - unsupported operand type(s) for ** or pow(): 'list' and 'int' error 如何修复此错误:** 或 pow() 不支持的操作数类型:'tuple' 和 'int' - How to fix this error: unsupported operand type(s) for ** or pow(): 'tuple' and 'int' ** 或 pow() 不支持的操作数类型:“str”和“int”错误 - unsupported operand type(s) for ** or pow(): 'str' and 'int' error 错误:** 或 pow() 不支持的操作数类型:'tuple' 和 'int' - Error: unsupported operand type(s) for ** or pow(): 'tuple' and 'int' 类型错误:** 或 pow() 不支持的操作数类型:'int' 和 'set' - TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'set' Python 3 TypeError:**或pow()不支持的操作数类型:“ str”和“ int” - Python 3 TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM