tensorlayer / TensorLayer

Deep Learning and Reinforcement Learning Library for Scientists and Engineers
http://tensorlayerx.com
Other
7.31k stars 1.61k forks source link

Weird code in batch normalization #1096

Open WyldeCat opened 4 years ago

WyldeCat commented 4 years ago

New Issue Checklist

Issue Description

https://github.com/tensorlayer/tensorlayer/blob/master/tensorlayer/layers/normalization.py#L291

        if self.axes is None:
            self.axes = [i for i in range(len(inputs.shape)) if i != self.channel_axis]

If I understood correctly, the above code is calculating axes to get means and variances for the normalization. But it looks weird to me because self.channel_axis can be -1. Shouldn't this change like this or something similar?

        if self.axes is None:
            self.axes = [i for i in range(len(inputs.shape)) if i != self.channel_axis]
            if self.channel_axis == -1:
                self.axes = self.axes[-1]
Laicheng0830 commented 3 years ago

Thanks! there is a problem with this code, we will fix it immediately.