Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phased_lstm_keras problem? add_weight () got multiple values for argument 'name' #19

Open
jabowery opened this issue Dec 13, 2019 · 4 comments

Comments

@jabowery
Copy link

The below error appeared in https://github.com/abr/neurips2019/blob/master/experiments/psMNIST-phased-lstm.ipynb

This has been reported as a keras issue with a suggested workaround. that may be applied in PhasedLSTM-Keras.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-c56ccd8ad126> in <module>
      4 model.add(PLSTM(200, input_shape=(n_pixels, 1), 
      5                 implementation=0,
----> 6                alpha=0.0001)
      7          )
      8 model.add(Dense(10, activation='softmax'))

~\Miniconda3\envs\lmu\lib\site-packages\keras\engine\sequential.py in add(self, layer)
    164                     # and create the node connecting the current layer
    165                     # to the input layer we just created.
--> 166                     layer(x)
    167                     set_inputs = True
    168             else:

~\Miniconda3\envs\lmu\lib\site-packages\keras\legacy\layers.py in __call__(self, inputs, initial_state, **kwargs)
    511         # modify the input spec to include the state.
    512         if initial_state is None:
--> 513             return super(Recurrent, self).__call__(inputs, **kwargs)
    514 
    515         initial_state = to_list(initial_state, allow_tuple=True)

~\Miniconda3\envs\lmu\lib\site-packages\keras\engine\base_layer.py in __call__(self, inputs, **kwargs)
    461                                          'You can build it manually via: '
    462                                          '`layer.build(batch_input_shape)`')
--> 463                 self.build(unpack_singleton(input_shapes))
    464                 self.built = True
    465 

~\Miniconda3\envs\lmu\lib\site-packages\phased_lstm_keras\PhasedLSTM.py in build(self, input_shape)
    190                                       initializer=self.kernel_initializer,
    191                                       regularizer=self.kernel_regularizer,
--> 192                                       constraint=self.kernel_constraint)
    193 
    194         self.recurrent_kernel = self.add_weight(

TypeError: add_weight() got multiple values for argument 'name'
@AndeYashwanth
Copy link

I tried the suggested fix but it doesn't work.
I still get the same error.

self.kernel = self.add_weight(shape=(self.input_dim, self.units * 4),
                                      name='kernel',
                                      initializer=self.kernel_initializer,
                                      regularizer=self.kernel_regularizer,
                                      constraint=self.kernel_constraint)

        self.recurrent_kernel = self.add_weight(
            shape=(self.units, self.units * 4),
            name='recurrent_kernel',
            initializer=self.recurrent_initializer,
            regularizer=self.recurrent_regularizer,
            constraint=self.recurrent_constraint)

        if self.use_bias:
            self.bias = self.add_weight(shape=(self.units * 4,),
                                        name='bias',
                                        initializer=self.bias_initializer,
                                        regularizer=self.bias_regularizer,
                                        constraint=self.bias_constraint)

@doubleapple123
Copy link

doubleapple123 commented Apr 7, 2020

There are 4 instances where you need to name the first argument as shape= , this seems to have fixed this particular issue for me, I think you're missing one

@zd23
Copy link

zd23 commented Jul 25, 2020

can you please show the 4 instance cz ive found 3 in mine too thanks in advance !
#doubleapple123

@AutoUpdatingBSoD
Copy link

@zd23
This is the code that ended up solving this issue for me.

        self.timegate_kernel = self.add_weight(
            shape=(3, self.units),
            name='timegate_kernel',
            initializer=self.timegate_initializer,
            regularizer=self.timegate_regularizer,
            constraint=self.timegate_constraint)
        self.built = True`

The code before is missing the explicit definition of shape=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants