错误提示:ValueError: When using JIT Fallback to handle script 'sum(pow(img_hash - sign(img_hash), 2))', the inputs should be constant, but found variable 'img_hash' to be nonconstant.
Mindspore中对Python的原生函数有独立支持,编译时会优先编译成原生函数,命名时一定要注意,例如:
sum = ops.ReduceSum() #sum()是python原生函数,换一个命名即可
sum_ = ops.ReduceSum()
在Mindspore中遇到ValueError,提示使用JITFallback处理sum(pow(img_hash-sign(img_hash),2))时,输入img_hash不应为变量。为解决此问题,需注意Python原生函数在Mindspore中的使用,如sum()应避免与Python内置函数冲突,可以改名为sum_并用ops.ReduceSum替代。
1423

被折叠的 条评论
为什么被折叠?



