You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/01/04 02:23:59 UTC
[GitHub] lupesko commented on issue #9288: Get HybridBlock layer shape on runtime
lupesko commented on issue #9288: Get HybridBlock layer shape on runtime
URL: https://github.com/apache/incubator-mxnet/issues/9288#issuecomment-355182832
Are you trying to get the input shape at runtime?
If so, `infer_shape` is not the right API.
You may want to try something like:
```
import mxnet as mx
import mxnet.ndarray as nd
from mxnet.gluon import HybridBlock
class runtime_shape(HybridBlock):
def __init__(self, **kwards):
HybridBlock.__init__(self,**kwards)
def hybrid_forward(self,F,_input):
print('input shape: {}'.format(_input.shape))
return _input
xx = nd.random_uniform(shape=[5,5,16,16])
mynet = runtime_shape()
mynet.hybrid_forward(nd,xx)
```
Which returns:
`input shape: (5L, 5L, 16L, 16L)`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services