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

[Numpy] Dense does not support float32 + float64. #18060

Closed
sxjscience opened this issue Apr 15, 2020 · 2 comments · Fixed by #18251
Closed

[Numpy] Dense does not support float32 + float64. #18060

sxjscience opened this issue Apr 15, 2020 · 2 comments · Fixed by #18251

Comments

@sxjscience
Copy link
Member

sxjscience commented Apr 15, 2020

The following code snippet will raise an error with the current MXNet. The reason is that the dtype of a will be float64 while the dense layer only supports float32.

import mxnet as mx
from mxnet.gluon import nn
import numpy as np
mx.npx.set_np()

net = nn.Dense(16)
net.initialize()

a = mx.np.array(np.ones((10, 4)))
out = net(a)
print(out)
MXNetError: Traceback (most recent call last):
  File "../src/io/../operator/elemwise_op_common.h", line 135
MXNetError: Check failed: assign(&dattr, vec.at(i)): Incompatible attr in node FullyConnected at 1-th input: expected float64, got float32
@yzhliu
Copy link
Member

yzhliu commented Apr 23, 2020

As discussed with @sxjscience before, one solution is to always convert to fp32 when reading from numpy array. what do you think? @reminisce @haojin2 @szha

@yzhliu
Copy link
Member

yzhliu commented Apr 30, 2020

We'll have an global default dtype switch, and it will be set to float32 if not changed by user.

JiangZhaoh added a commit to JiangZhaoh/incubator-mxnet that referenced this issue Apr 30, 2020
JiangZhaoh added a commit to JiangZhaoh/incubator-mxnet that referenced this issue May 6, 2020
@JiangZhaoh JiangZhaoh mentioned this issue May 6, 2020
7 tasks
JiangZhaoh added a commit to JiangZhaoh/incubator-mxnet that referenced this issue May 12, 2020
yzhliu pushed a commit that referenced this issue May 19, 2020
* apply #17283

* fix issue #18060

* fix error

* remove redundant code

* fix CI error

* replace Flase to False

* add 'dtype=False' to set_np()

* fix doc

* default 'arange' default np dtype as int64
AntiZpvoh pushed a commit to AntiZpvoh/incubator-mxnet that referenced this issue Jul 6, 2020
* apply apache#17283

* fix issue apache#18060

* fix error

* remove redundant code

* fix CI error

* replace Flase to False

* add 'dtype=False' to set_np()

* fix doc

* default 'arange' default np dtype as int64
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