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 2017/12/30 21:42:15 UTC

[GitHub] sxjscience commented on issue #9264: Some questions about gluon

sxjscience commented on issue #9264: Some questions about gluon
URL: https://github.com/apache/incubator-mxnet/issues/9264#issuecomment-354569930
 
 
   @kice We cannot use list to store Blocks because they will not be registered correctly. You may refer to this PR for more information https://github.com/apache/incubator-mxnet/pull/9148.
   
   One solution to this problem is to use Sequential or HybridSequential as a container to the Conv Layers. For example:
   ```python
   class Layer(nn.HybridBlock):
       def __init__(self, depth=15, channels=3, **kwargs):
           super(Layer, self).__init__(**kwargs)
           self.conv_layers = nn.HybridSequential
           with self.conv_layers.name_scope():
                for i in range(depth):
                     self.conv_layers.add(nn.Conv2D(128, kernel_size=3, strides=1, padding=1, use_bias=True))
      def hybrid_forward(self, F, x):
          # You can use the layers as self.conv_layers[i]
   ```
   
   @szha @piiswrong In PyTorch, there is an additional ModuleList object (http://pytorch.org/docs/master/nn.html#torch.nn.ModuleList) for this behavoir. Do you think we need to add this? (Sequential and HybridSequential already have the functionality of "BlockList")

----------------------------------------------------------------
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