singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [singa] nudles commented on pull request #688: Autograd refactor
Date Thu, 14 May 2020 09:14:51 GMT

nudles commented on pull request #688:
URL: https://github.com/apache/singa/pull/688#issuecomment-628507144


   The following APIs should be backward compatible. Please test.
   
   ```python
   
   class Linear(Layer):
        def __init__(self, num_output, *args, bias=True, **kwargs):
             # the following block is for backward compatibility. 
             # the old code will all Linear(2, 3), or (2, 3, False)
             if len(args) > 0:
                num_input = num_output
                num_output = args[0]
             if len(args) > 1:
                bias = args[1]
   
          self.num_output = num_output
          self.bias = bias
   
   class Conv2d(Layer):
          def __init__(self,
                    out_channels,
                    kernel_size,
                    *args,
                    stride=1,
                    padding=0,
                    dilation=1,
                    group=1,
                    bias=True,
                    pad_mode="NOTSET",
                    **kwargs):
            # the old code create the layer like: Conv2d(8, 16, 3), or Conv2d(8, 16, 3,
stride=1)
            # the following code block is for backward compatibility
            if len(args) >0:
              in_channel=out_channel
              out_channel = kernel
              kernel = args[0]
            if len(args) > 1:
              stride = args[1]
            if len(args) > 2:
              padding = args[2]
    ```
   
   
   
   
            


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



Mime
View raw message