-
Notifications
You must be signed in to change notification settings - Fork 142
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
AssertionError for the more-than-two-dimensional input of nn.Linear #18
Comments
if I want to get the calculation analysis of a fc layer, how can I use this tool?
I wrote this code, but assert len(inp.size()) == 2 and len(out.size()) == 2 cannot pass, how can i change the code? |
Any update on this Issue? |
1 similar comment
Any update on this Issue? |
flops = (torch.prod(torch.LongTensor(out.size()))*inp.size(-1)).item() |
Maybe add the channels, otherwise the flops may be incorrect |
Thanks to bighuang624's answer. The reason why AssertionError "assert len(inp.size()) == 2 and len(out.size()) == 2" exists is "the input of the linear layer is not only two-dimensional".There is my solution:
|
Considering that the input of the linear layer is not necessarily only two-dimensional, I think these changes
assert len(inp.size()) == 2 and len(out.size()) == 2
toassert len(inp.size()) >= 2 and len(out.size()) >= 2
inp.size()[1]
andout.size()[1]
toinp.size()[-1]
andout.size()[-1]
should be made in these functions
def compute_Linear_memory(module, inp, out)
incompute_memory.py
def compute_Linear_madd(module, inp, out)
incompute_madd.py
def compute_Linear_flops(module, inp, out)
incompute_flops.py
I am not quite sure that such changes are correct. And sorry for my poor English.
The text was updated successfully, but these errors were encountered: