Skip to content

Weight initialization in custom Conv3d seems different from nn.Conv3d #88

@qy-777

Description

@qy-777

Hi, I noticed that the outputs from my custom Conv3d and PyTorch’s nn.Conv3d were very different,
so I added some simple print() statements in both constructors (added at level1 question 60)
to check their weights.

Here’s what I got:

[RefModel] in=3, out=64, kernel=(3, 5, 7), stride=1, padding=0, bias=False
[RefModel Conv3d] weight shape: (64, 3, 3, 5, 7)
mean=-0.000240, std=0.032601, min=-0.056343, max=0.056341

[ModelNew] in=3, out=64, kernel=(3, 5, 7), stride=1, padding=(0, 0, 0), bias=False
[ModelNew Conv3d] weight shape: (64, 3, 3, 5, 7)
mean=0.009656, std=1.001391, min=-4.590487, max=4.220885

The shapes match, but the distributions are very different — nn.Conv3d has much smaller weights (std≈0.03),
while the custom one uses torch.randn() (std≈1.0).
This likely causes large output differences even if the kernels are correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions