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 2020/03/14 02:25:01 UTC

[GitHub] [incubator-mxnet] umutisik edited a comment on issue #4901: Is it possible to do "broadcast_concat"?

umutisik edited a comment on issue #4901: Is it possible to do "broadcast_concat"?
URL: https://github.com/apache/incubator-mxnet/issues/4901#issuecomment-598998912
 
 
   The following works for me:
   ```python
   class TestModel(gluon.HybridBlock):
       def __init__(self, **kwargs):
           super(TestModel, self).__init__(**kwargs)
           # self.c2 = self.params.get_constant('c2', [[1,2,3]])
           self.c2 = self.params.get_constant('c2', np.arange(12).reshape([1,3,2,2]).tolist()) # 1,3,2,2
           self.compa = 1.
           
       def hybrid_forward(self, F, x, **kwargs):
           c = F.broadcast_to(kwargs['c2'], shape=(-1, 0, 0, 0)) 
           return F.concat(c, x, dim=1) 
   
   model = TestModel()
   model.hybridize()
   model.initialize()
   x = np.ones([5,5,2,2])*100.
   x = nd.array(x)
   out = model(x)
   print(out.shape)
   print(out[0, 0])
   print(out[0, 3])
   ```
   
   Shape -1 is not supported in ndarray though.
   But I only needed the non-fixed size in symbol. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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