singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-singa] joddiy commented on issue #541: added 4d test on batchnorm
Date Thu, 10 Oct 2019 14:01:37 GMT
joddiy commented on issue #541: added 4d test on batchnorm
URL: https://github.com/apache/incubator-singa/pull/541#issuecomment-540600410
 
 
   hi, shicong, the result still has a little error, please check with the following case:
   ```
           def _batchnorm_test_mode(x, s, bias, mean, var, epsilon=1e-5):  # type: ignore
               dims_x = len(x.shape)
               dim_ones = (1,) * (dims_x - 2)
               s = s.reshape(-1, *dim_ones)
               bias = bias.reshape(-1, *dim_ones)
               mean = mean.reshape(-1, *dim_ones)
               var = var.reshape(-1, *dim_ones)
               return s * (x - mean) / np.sqrt(var + epsilon) + bias
   
           # input size: (1, 2, 1, 3)
           x = np.array([[[[-1, 0, 1]], [[2, 3, 4]]]]).astype(np.float32)
           s = np.array([1.0, 1.5]).astype(np.float32)
           bias = np.array([0, 1]).astype(np.float32)
           mean = np.array([0, 3]).astype(np.float32)
           var = np.array([1, 1.5]).astype(np.float32)
           y = _batchnorm_test_mode(x, s, bias, mean, var).astype(np.float32)
   ```

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

Mime
View raw message