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

a mistake in the "train.py" #3

Open
1996Wanglei opened this issue Nov 11, 2019 · 3 comments
Open

a mistake in the "train.py" #3

1996Wanglei opened this issue Nov 11, 2019 · 3 comments

Comments

@1996Wanglei
Copy link

1996Wanglei commented Nov 11, 2019

hello jason,
thanks for your implementation! good job!
however, when i wanted to train the music transformer, i found that there is a mistake in the "train.py".
i received this error:
Traceback (most recent call last):
File "train.py", line 92, in
metrics = metric_set(sample, batch_y)
File "/home/mirlab2019/wanglei/MusicTransformer-pytorch/custom/metrics.py", line 69, in call
return self.forward(input=input, target=target)
File "/home/mirlab2019/wanglei/MusicTransformer-pytorch/custom/metrics.py", line 75, in forward
for k, metric in self.metrics.items()}
File "/home/mirlab2019/wanglei/MusicTransformer-pytorch/custom/metrics.py", line 75, in
for k, metric in self.metrics.items()}
AttributeError: 'tuple' object has no attribute 'to'

After further discovering, i found that the reason is that a tuple is returned in the line 91, train.py. And then the returned tuple is transferred to "metric_set()", however "metric_set()" should receive a tensor instead of a tuple. Actually, adding a new variable to receive the returned attention weights could avoid the above error.

@mzliang-annie
Copy link

Do you know how to fix this in code?

@mzliang-annie
Copy link

mzliang-annie commented Dec 20, 2019

        if self.training:
            return fc.contiguous()
        else:
            return fc.contiguous(), [weight.contiguous() for weight in w]

Separate the original line 43 in model.py to the above, just solve the issue

@adamoudad
Copy link
Contributor

I made a PR #11 to fix this.

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