Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Floating point exception in mxnet.ndarray.InstanceNorm #18933

Closed
leeyeetonn opened this issue Aug 15, 2020 · 1 comment · Fixed by #18974
Closed

Floating point exception in mxnet.ndarray.InstanceNorm #18933

leeyeetonn opened this issue Aug 15, 2020 · 1 comment · Fixed by #18974

Comments

@leeyeetonn
Copy link

Description

(A clear and concise description of what the bug is.)
mxnet.ndarray.InstanceNorm has floating point exception when the given data's batch = 0 or channel = 0. Please see the provided code snippets for example.

Error Message

(Paste the complete error message. Please also include stack trace by setting environment variable DMLC_LOG_STACK_TRACE_DEPTH=10 before running your script.)

Floating point exception (core dumped)

To Reproduce

(If you developed your own code, please provide a short script that reproduces the error. For existing examples, please provide link.)

import mxnet
import numpy as np

input = mxnet.nd.array(np.random.rand(0,1,1)) # batch = 0
gamma = mxnet.nd.array(np.random.rand(1))
beta = mxnet.nd.array(np.random.rand(1))
mxnet.ndarray.InstanceNorm(input, gamma, beta)
import mxnet
import numpy as np

input = mxnet.nd.array(np.random.rand(1,0,1)) # channel = 0
gamma = mxnet.nd.array(np.random.rand(0))
beta = mxnet.nd.array(np.random.rand(0))
mxnet.ndarray.InstanceNorm(input, gamma, beta)

Steps to reproduce

(Paste the commands you ran that produced the error.)

  1. run the provided code in python interpreter or as a script

What have you tried to solve it?

Environment

We recommend using our script for collecting the diagnositc information. Run the following command and paste the outputs below:

curl --retry 10 -s https://github.com/dmlc/gluon-nlp/master/tools/diagnose.py | python

# paste outputs here

Got 404 when trying to get the script.

Some environment information:

  • OS: ubuntu 18.04
  • Python: 3.7.6
  • pip: 20.0.2
  • numpy: 1.18.5
  • mxnet: 1.6.0
@szha
Copy link
Member

szha commented Aug 20, 2020

Confirmed that this issue also happens in numpy branch. Since instance norm was using a legacy operator interface, I will refactor it to use the new operator interface and register an npx namespace alias.

from mxnet import np, npx

npx.set_np()

input = np.random.rand(0,1,1) # batch = 0
gamma = np.random.rand(1)
beta = np.random.rand(1)
npx.instance_norm(input, gamma, beta)
from mxnet import np, npx

npx.set_np()

input = np.random.rand(1,0,1) # channel = 0
gamma = np.random.rand(1)
beta = np.random.rand(1)
npx.instance_norm(input, gamma, beta)

szha added a commit to szha/mxnet that referenced this issue Aug 21, 2020
@szha szha mentioned this issue Aug 21, 2020
7 tasks
szha added a commit to szha/mxnet that referenced this issue Aug 21, 2020
szha added a commit that referenced this issue Aug 21, 2020
* refactor instance norm with new op interface

* fix #18933

* fix backward

* fix gpu
chinakook pushed a commit to chinakook/mxnet that referenced this issue Nov 17, 2020
* refactor instance norm with new op interface

* fix apache#18933

* fix backward

* fix gpu
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants