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

sym.Variable input init need init.dumps(), but NDarray is not JSON serializable #15927

Closed
david-di opened this issue Aug 16, 2019 · 3 comments
Closed

Comments

@david-di
Copy link

Description

mxnet.symbol.Variable(name, attr=None, shape=None, lr_mult=None, wd_mult=None, dtype=None, init=None, stype=None, **kwargs)
The input parameter init, I used mxnet.initializer.Constant(value).
The introduction of Constant class says "Initializes the weights to a given value. The value passed in can be a scalar or a NDarray that matches the shape of the parameter to be set", so I use a NDarray as "value" parameter.
Now, accident happened......
In class Variable, if init is not an instance of string, init.dumps() will be called.
"dumps" method is implemented in class mxnet.initializer.Initializer, the superclass of Constant.

def dumps(self):
  return json.dumps([self.__class__.__name__.lower(), self._kwargs])

NDarray is not JSON serializable...
Crash...

@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Bug, Feature

@abhinavs95
Copy link
Contributor

@david-di This has been already fixed by #15150 but was merged after 1.5 release. Its not reproducible in latest pip.

Could you try with pip install mxnet --pre?

@leleamol
Copy link
Contributor

leleamol commented Aug 28, 2019

@mxnet-label-bot add [Pending Requester Info]

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

No branches or pull requests

7 participants