Skip to content

Weights of custom layers not counted #65

@mostafaelhoushi

Description

@mostafaelhoushi

I have created my own custom layer or module and found its parameters are not counted properly in the summary.
Looking at the code, I found this could be the reason:

            if hasattr(module, "weight") and hasattr(module.weight, "size"):
                params += torch.prod(torch.LongTensor(list(module.weight.size())))
                summary[m_key]["trainable"] = module.weight.requires_grad
            if hasattr(module, "bias") and hasattr(module.bias, "size"):
                params += torch.prod(torch.LongTensor(list(module.bias.size())))

So basically it is looking for parameters named weight or bias. I think it will be great if the code is updated to handle generic trainable parameter names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions