You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/09/06 06:45:22 UTC

[GitHub] danache commented on issue #7758: How can I use UpSampling or add_n function in gluon?

danache commented on issue #7758: How can I use UpSampling or add_n function in gluon?
URL: https://github.com/apache/incubator-mxnet/issues/7758#issuecomment-327390743
 
 
   Thanks for your reply !I follow your instruction and build the net as this:
   from mxnet import gluon
   ```
   class poolLayer(gluon.HybridBlock):
       def __init__(self, numOut,**kwargs):
           super(poolLayer, self).__init__(**kwargs)
           with self.name_scope():
               self.bn1 = gluon.nn.BatchNorm(axis=1, center=True, scale=True)
               self.relu1 = gluon.nn.Activation(activation='relu')
               self.pool1 = gluon.nn.MaxPool2D(pool_size=2)
               
               self.conv1 = gluon.nn.Conv2D(channels=numOut, kernel_size=3, strides=1, padding=1)
               self.bn2 = gluon.nn.BatchNorm(axis=1, center=True, scale=True)
               self.relu2 = gluon.nn.Activation(activation='relu')
               
               self.conv2 = gluon.nn.Conv2D(channels=numOut, kernel_size=3, strides=1, padding=1)
       def hybrid_forward(self, F, x):
           # F is a function space that depends on the type of x
           # If x's type is NDArray, then F will be mxnet.nd
           # If x's type is Symbol, then F will be mxnet.sym
           print('type(x): {}, F: {}'.format(
                   type(x).__name__, F.__name__))
           x = self.bn1(x)
           x = self.relu1(x)
           x = self.pool1(x)
           x = self.conv1(x)
           x = self.bn2(x)
           x = self.relu2(x)
           
           x = self.conv2(x)
           x = F.UpSampling(x,scale=2,sample_type = 'nearest')
           
           return x
   ```
   could you tell me if it is right? Thx a lot!
 
----------------------------------------------------------------
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