MarcBS / keras

Keras' fork with several new functionalities. Caffe2Keras converter, multimodal layers, etc.
https://github.com/MarcBS/keras
Other
225 stars 58 forks source link

TypeError: __call__() takes 2 positional arguments but 4 were given #56

Open Imorton-zd opened 6 years ago

Imorton-zd commented 6 years ago
decoder_inputs = Input(shape=((None, num_decoder_tokens)))

decoder_layer = AttGRUCond(latent_dim,return_sequences=True)
decoder_outputs, states = decoder_layer(decoder_inputs,encoder_outputs,state)

decoder_dense = Dense(num_decoder_tokens, activation='softmax')
decoder_seqs = decoder_dense(decoder_outputs)

When using the AttGRUCond layer, the above code snippet yields a type error:

  File "D:/intern/experiments/myAtt_with_custom.py", line 183, in <module>
    decoder_outputs, sts = decoder_layer(decoder_inputs,encoder_outputs,state)

TypeError: __call__() takes 2 positional arguments but 4 were given

I would like to ask if the way using this layer is right? Thanks.

lvapeab commented 6 years ago

Hi @Imorton-zd ,

you'll probably need to pass the inputs to that layer as a list:

decoder_outputs, states = decoder_layer([decoder_inputs,encoder_outputs,state])

Imorton-zd commented 6 years ago

Hi @lvapeab, thanks for your suggestion. However, I got another error after modification as your post.

Traceback (most recent call last):

  File "<ipython-input-92-3a7350e5c38d>", line 1, in <module>
    runfile('D:/intern/experiments/myAtt_with_custom.py', wdir='D:/intern/experiments')

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "D:/intern/experiments/myAtt_with_custom.py", line 183, in <module>
    decoder_outputs, sts = decoder_layer([decoder_inputs,encoder_outputs,state])

  File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\topology.py", line 592, in __call__
    self.build(input_shapes)

  File "D:\intern\experiments\myRecurrent.py", line 1140, in build
    regularizer=self.ba_regularizer)

  File "C:\ProgramData\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)

TypeError: add_weight() got multiple values for argument 'name'

The error is also met at the decoder_layer line. Where is the mistake?

Imorton-zd commented 6 years ago

Hi, @MarcBS , please help me solve this problem when you have some time.

MarcBS commented 6 years ago

Hi, @Imorton-zd , if you show us your code maybe we will be able to give you some hint about what might be failing.