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/09/28 02:55:55 UTC
[GitHub] feevos commented on issue #9288: Get HybridBlock layer shape on
runtime
feevos commented on issue #9288: Get HybridBlock layer shape on runtime
URL: https://github.com/apache/incubator-mxnet/issues/9288#issuecomment-425305179
Hi @ShoufaChen, your problem is easy, see [nd.array.reshape](https://mxnet.incubator.apache.org/api/python/ndarray/ndarray.html#mxnet.ndarray.NDArray.reshape) operation. The same exists for Symbol
```Python
class CustomNet(HybridBlock):
def __init__(self,**kwards):
HybridBlock.__init__(self,**kwards)
with self.name_scope():
# do something here
def hybrid_forward(self,F,input):
# reshape input with product of two last dimensions
b = F.reshape(input,shape=[0,0,-3])
# now b has dimensions input.shape[0],input.shape[0],input.shape[2] * input.shape[3]
return b
```
you can use this trick inside your custom layer definition. Hope this helps.
----------------------------------------------------------------
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