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

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

Open
Imorton-zd opened this issue Mar 29, 2018 · 4 comments
Open

Comments

@Imorton-zd
Copy link

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
Copy link
Collaborator

lvapeab commented Mar 29, 2018

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
Copy link
Author

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
Copy link
Author

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

@MarcBS
Copy link
Owner

MarcBS commented Apr 12, 2018

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

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

3 participants