问题描述:
【功能模块】
mindspore 1.5
【操作步骤&问题现象】
1、自定义损失函数,传入网络的输出和标签进行计算。
2、mindspore.ops.operations.math_ops.Square使用时,运行报错如下。
【截图信息】
解答:
写法问题,请参考 https://www.mindspore.cn/docs/programming_guide/zh-CN/r1.6/cell.html 中Cell的写法:在__init__函数里定义self.square = P.Square(),在construct里调用self.square(label)
或者在construct里直接调用P.Square()(label),而不是将label直接传给P.Square。你的脚本里其他写法都存在这种问题