tensorlayer / TensorLayer

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

BatchNorm1d IndexError: list index out of range #1039

Closed zsdonghao closed 5 years ago

zsdonghao commented 5 years ago

My code as follow:

    ni2 = Input(shape=[None, flags.z2_dim])
    ni2 = Dense(100, W_init=w_init, b_init=None)(ni2)
    ni2 = BatchNorm1d(decay=0.9, act=act, gamma_init=gamma_init)(ni2)

I got the following error.

  File "/home/asus/Workspace/dcgan-disentangle/model.py", line 18, in get_generator
    ni2 = BatchNorm1d(decay=0.9, act=act, gamma_init=gamma_init)(ni2)
  File "/home/asus/Workspace/dcgan-disentangle/tensorlayer/layers/core.py", line 238, in __call__
    self.build(inputs_shape)
  File "/home/asus/Workspace/dcgan-disentangle/tensorlayer/layers/normalization.py", line 250, in build
    params_shape, self.axes = self._get_param_shape(inputs_shape)
  File "/home/asus/Workspace/dcgan-disentangle/tensorlayer/layers/normalization.py", line 311, in _get_param_shape
    channels = inputs_shape[axis]
IndexError: list index out of range

According to the docs, BatchNorm1d only works for input shape of [batch, xxx, xxx] ? How about [batch, xxx]?

    >>> # in static model, no need to specify num_features
    >>> net = tl.layers.Input([None, 50, 32], name='input')
    >>> net = tl.layers.BatchNorm1d()(net)
    >>> # in dynamic model, build by specifying num_features
    >>> conv = tl.layers.Conv1d(32, 5, 1, in_channels=3)
    >>> bn = tl.layers.BatchNorm1d(num_features=32)
ChrisWu1997 commented 5 years ago

I'm fixing this. Temporally, you can just use BatchNorm instead of BatchNorm1d since BatchNorm works for all when using static model.

zsdonghao commented 5 years ago

Thanks