-
Notifications
You must be signed in to change notification settings - Fork 46
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
Hi,after I replace the code ,please help #12
Comments
|
Thank you!
but after I replace the code
new error:
RuntimeError: The expanded size of the tensor (128) must match the existing size (3) at non-singleton dimension 0
I modify:
norm_weight = self.weight * (weight_scale[None,:,None,None] / (torch.sqrt((self.weight ** 2).sum(3,keepdim=True).sum(2,keepdim=True).sum(0,keepdim=True) + 1e-6)).expand_as(self.weight))
is ok.
But new error is:
File "/home/gis/PycharmProjects/guo/ssl_bad_gan-master/utils.py", line 34, in log_sum_exp
return ((logits - max_logits.expand_as(logits)).exp()).sum(1,keepdim=True).log().squeeze() + max_logits.squeeze()
RuntimeError: The expanded size of the tensor (10) must match the existing size (64) at non-singleton dimension 1
logits and max_logits.expand_as(logits) is nomatch!
should I do?
Thank you
|
Hi,
It is the problem of tensor dimension.
Just replace the code
norm_weight = self.weight * (weight_scale[None,:,None,None] / torch.sqrt((self.weight ** 2).sum(3).sum(2).sum(0) + 1e-6)).expand_as(self.weight)
with
norm_weight = self.weight * (weight_scale[None,:,None,None] / torch.sqrt((self.weight ** 2).sum(3).sum(2).sum(0) + 1e-6).reshape([-1, 1, 1, 1])).expand_as(self.weight)
Originally posted by @zcwang0702 in #6 (comment)
but after I replace the code
new error:
RuntimeError: The expanded size of the tensor (128) must match the existing size (3) at non-singleton dimension 0
original code error :
File "/home/gis/PycharmProjects/guo/ssl_bad_gan-master/model.py", line 165, in forward
norm_weight = self.weight * (weight_scale[None,:,None,None] / torch.sqrt((self.weight ** 2).sum(3).sum(2).sum(0) + 1e-6)).expand_as(self.weight)
RuntimeError: The expanded size of the tensor (5) must match the existing size (3) at non-singleton dimension 3
Thank you!
The text was updated successfully, but these errors were encountered: