使用mindspore.numpy.sqrt 计算结果不正确
收藏回复举报
使用mindspore.numpy.sqrt 计算结果不正确
发表于2023-07-29 16:40:51
0 查看

1 系统环境

硬件环境(Ascend/GPU/CPU): Ascend/GPU/CPU

MindSpore版本: mindspore=2.0.0

执行模式(PyNative/ Graph):不限

Python版本: Python=3.7

操作系统平台: 不限

2 报错信息

2.1 问题描述

mindspore.numpy.sqrt 在图模式下 int输入结果不对,在pynative模式报错。两种模式结果不一致。全部报错,或者全部为 2.236

2.3 脚本代码(代码格式,可上传附件)

import mindspore as ms
import mindspore.nn as nn

class TestModel(nn.Cell):
    def construct(self, x):
        x = ms.numpy.sqrt(x.shape[-1])
        return x

inputs = ms.Tensor([1, 2, 3, 4, 5])
model = TestModel()

ms.set_context(mode=0)
print(model(inputs))

ms.set_context(mode=1)
print(model(inputs))

3 根因分析

******此处由用户补充详细的定位过程******

4 解决方案

******此处由用户填写******

包含文字方案和最终脚本代码

请将正确的脚本打包并上传附件

00.PNG

我要发帖子