2.4K Star 8.1K Fork 4.3K

GVPMindSpore / mindspore

 / 详情

The relu operator has a value of 0 after nan

TODO
RFC
创建于  
2024-05-06 21:20
name about labels
Bug Report Use this template for reporting a bug kind/bug

Describe the current behavior / 问题描述 (Mandatory / 必填)

The value of the relu operator on mindspore after passing through nan is 0. And the value of the relu operator on pytorch after passing through nan is still nan.

Environment / 环境信息 (Mandatory / 必填)

  • Hardware Environment(Ascend/GPU/CPU) / 硬件环境:

Please delete the backend not involved / 请删除不涉及的后端:
/device /CPU/

  • Software Environment / 软件环境 (Mandatory / 必填):
    -- MindSpore version (e.g., 1.7.0.Bxxx) :2.2.0
    -- Torch version (e.g., 1.7.0.Bxxx) :2.0.0+cpu
    -- Python version (e.g., Python 3.7.5) :3.8.16
    -- OS platform and distribution (e.g., Linux Ubuntu 16.04):Linux Ubuntu 18.04.6 LTS

  • Excute Mode / 执行模式 (Mandatory / 必填)(PyNative/Graph):

Please delete the mode not involved / 请删除不涉及的模式:
/mode pynative

Related testcase / 关联用例 (Mandatory / 必填)

import mindspore.ops
import torch
import mindspore
import numpy as np


def mindspore_relu():
    print("*************mindspore_relu()**************")
    input_np = np.load("./tensor_50.npy")

    input_tensor = mindspore.Tensor(input_np)
    output = mindspore.ops.relu(input=input_tensor)
    is_nan = mindspore.ops.IsNan()
    print("input has nan",is_nan(input_tensor).any())
    print("output has nan",is_nan(output).any())

def torch_relu():
    print("*************torch_relu()**************")
    input_np = np.load("./tensor_50.npy")
    input_tensor = torch.Tensor(input_np)
    output = torch.relu(input_tensor)
    print("input has nan",torch.isnan(input_tensor).any())
    print("output has nan",torch.isnan(output).any())

    
if __name__ == "__main__":
    mindspore_relu()
    torch_relu()

tensor_50.npy

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

  1. running code

Describe the expected behavior / 预期结果 (Mandatory / 必填)

After the relu operator on the mindspore has been computed by nan, the output should still be nan

Related log / screenshot / 日志 / 截图 (Mandatory / 必填)

输入图片说明

评论 (3)

CZXIANGOVO 创建了Bug-Report

Please assign maintainer to check this issue.
请为此issue分配处理人。
@fangwenyi @chengxiaoli @Shawny

感谢您的提问,您可以评论//mindspore-assistant更快获取帮助:

  1. 如果您刚刚接触MindSpore,或许您可以在教程找到答案
  2. 如果您是资深Pytorch用户,您或许需要:
  1. 如果您遇到动态图问题,可以设置set_context(pynative_synchronize=True)查看报错栈协助定位
  2. 模型精度调优问题可参考官网调优指南
  3. 如果您反馈的是框架BUG,请确认您在ISSUE中提供了MindSpore版本、使用的后端类型(CPU、GPU、Ascend)、环境、训练的代码官方链接以及可以复现报错的代码的启动方式等必要的定位信息
  4. 如果您已经定位出问题根因,欢迎提交PR参与MindSpore开源社区,我们会尽快review
CZXIANGOVO 修改了描述
CZXIANGOVO 修改了描述
Shawny 负责人设置为hedongdong
Shawny 任务类型Bug-Report 修改为Question
Shawny 关联项目设置为MindSpore Issue Assistant
Shawny 计划开始日期设置为2024-05-09
Shawny 计划截止日期设置为2024-06-09
Shawny 任务类型Question 修改为RFC
Shawny 添加了
 
mindspore-assistant
标签
Shawny 添加了
 
sig/ops
标签

暂未定义该算子输入为Nan时的行为,当前与Torch表现不一致。
会在未来的版本中支持该场景。

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(3)
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore

搜索帮助

53164aa7 5694891 3bd8fe86 5694891