umutisik commented 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.arange(100).reshape([5,5,2,2])*100.
   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:
[email protected]


With regards,
Apache Git Services

Reply via email to