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

Support None as input in forward and hybrid_forward? #13247

Closed
yifeim opened this issue Nov 13, 2018 · 6 comments
Closed

Support None as input in forward and hybrid_forward? #13247

yifeim opened this issue Nov 13, 2018 · 6 comments

Comments

@yifeim
Copy link
Contributor

yifeim commented Nov 13, 2018

Description

(Hybrid) forward supports None as defaults, but not as inputs. I was wondering if there are any fundamental reasons why None cannot be taken as input - if the pattern is consistent and I do not change the computation graph? Similarly, None in the output should also be allowed.

Environment info (Required)

----------Python Info----------
Version      : 3.6.5
Compiler     : GCC 7.2.0
Build        : ('default', 'Apr 29 2018 16:14:56')
Arch         : ('64bit', '')
------------Pip Info-----------
Version      : 10.0.1
Directory    : /home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/pip
----------MXNet Info-----------
Version      : 1.3.0
Directory    : /home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet
Commit Hash   : b3be92f4a48bce62a5a8424271871c2f81c8f7f1
----------System Info----------
Platform     : Linux-4.14.77-69.57.amzn1.x86_64-x86_64-with-glibc2.9
system       : Linux
node         : ip-172-16-72-155
release      : 4.14.77-69.57.amzn1.x86_64
version      : #1 SMP Tue Nov 6 21:32:55 UTC 2018
----------Hardware Info----------
machine      : x86_64
processor    : x86_64
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0016 sec, LOAD: 0.4079 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.1175 sec, LOAD: 0.1057 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.2767 sec, LOAD: 0.1359 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0274 sec, LOAD: 0.1023 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0023 sec, LOAD: 0.3404 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0081 sec, LOAD: 0.3184 sec.

Package used (Python/R/Scala/Julia):
Python

Error Message:

AssertionError: HybridBlock input must be (nested) list of Symbol or NDArray, but got None of type <class 'NoneType'>
AssertionError: HybridBlock output must be (nested) list of Symbol or NDArray, but got None of type <class 'NoneType'>

Minimum reproducible example

import mxnet as mx
rnn = mx.gluon.rnn.GRU(10)
rnn.hybridize()
rnn.collect_params().initialize()
rnn(mx.nd.zeros((3,2,10)), ) # this is okay
rnn(mx.nd.zeros((3,2,10)), None) # this is not okay

Steps to reproduce

  1. The example is self-contained.

What have you tried to solve it?

  1. Manually construct an *args list, which seems error-prone.
@zachgk
Copy link
Contributor

zachgk commented Nov 13, 2018

@mxnet-label-bot add [Feature Request, Python, Gluon]

@yifeim
Copy link
Contributor Author

yifeim commented Nov 13, 2018

@zachgk Thanks! I should also mention that None output type should also be similarly allowed for completeness. Will edit the original feature request.

@zachgk
Copy link
Contributor

zachgk commented Nov 14, 2018

Thank you for the suggestion @yifeim. We welcome contributions, so feel free to try making these changes yourself if you want to get involved

@yifeim
Copy link
Contributor Author

yifeim commented Nov 14, 2018

Thanks for the offers, but I don’t think I need to fix it in a hurry, because I have my workaround. Mxnet for me still seems to have large amount of obvious hacks or bugs, understandably. Nonetheless, I like the better side of mxnet.

I appreciate that you feel this is an sensible suggestion and an obvious thing to do. Will revisit later.

@sxjscience
Copy link
Member

@yifeim Should be solved by #16280

@sxjscience
Copy link
Member

@yifeim Currently, only supports None as the input.

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

4 participants