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

Error when not using any distance penalty #12

Open
gegallego opened this issue Mar 9, 2021 · 2 comments
Open

Error when not using any distance penalty #12

gegallego opened this issue Mar 9, 2021 · 2 comments

Comments

@gegallego
Copy link

Hello @mattiadg

When I don't use the --distance-penalty flag I get the following error:

File "~/FBK-Fairseq-ST/fairseq/models/s_transformer.py", line 472, in __init__
    init_variance=(args.init_variance if args.distance_penalty == 'gauss' else None)
TypeError: __init__() got an unexpected keyword argument 'penalty'

The problem comes from the following lines in the constructor of TransformerEncoderLayer:

attn = LocalMultiheadAttention if args.distance_penalty != False else MultiheadAttention	
self.self_attn = attn(
	self.embed_dim, args.encoder_attention_heads,
	dropout=args.attention_dropout, penalty=args.distance_penalty,
	init_variance=(args.init_variance if args.distance_penalty == 'gauss' else None)
)

The argumentspenalty and init_variance do not exist in MultiheadAttention, so I substituted these lines by:

if args.distance_penalty != False:
    self.self_attn = LocalMultiheadAttention(
        self.embed_dim, args.encoder_attention_heads,
        dropout=args.attention_dropout, penalty=args.distance_penalty,
        init_variance=(args.init_variance if args.distance_penalty == 'gauss' else None)
    )
else:
    self.self_attn = MultiheadAttention(
        self.embed_dim, args.encoder_attention_heads,
        dropout=args.attention_dropout,
    )
@mattiadg
Copy link
Owner

mattiadg commented Mar 9, 2021

Do you want to submit a pull request?

@gegallego
Copy link
Author

👍

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

Successfully merging a pull request may close this issue.

2 participants