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

Why do the resnet50 results of arm neon cnn not correspond to pytorch? #1076

Open
NNUCJ opened this issue Oct 30, 2023 · 0 comments
Open

Why do the resnet50 results of arm neon cnn not correspond to pytorch? #1076

NNUCJ opened this issue Oct 30, 2023 · 0 comments
Assignees
Milestone

Comments

@NNUCJ
Copy link

NNUCJ commented Oct 30, 2023

  1. MY Goal:
       Using arm neon CNN to build resnet50 and compare the results with Pytorch. I have saved weights of Pytorch as numpy, and loaded the corresponding weights on Neon CNN.

  2. Problems:
       The value of Feature Map cannot be aligned with Pytorch starting from the 3x3 conv2d() layer of the first bottleneck(The section between # comments in the network structure of the following code).

ResNet(
  (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
  (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
  (relu): ReLU(inplace=True)
  (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
  (layer1): Sequential(
    (0): Bottleneck(
      (conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
      (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      ##########################
      [error begin]
      (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
      (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      (conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
      (bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      (relu): ReLU(inplace=True)
    ############################
      (downsample): Sequential(
        (0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
        (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
    )
  1. Test Script
      Using the same input data and convolutional weights(download link) to compare the output results of conv2d in acl and pytorch。
  • pytorch
input = np.load("input.npy")
conv2_weights = np.load("layer1_0_conv2_weight.npy")
state_dict = {"weight": torch.from_numpy(conv2_weights)}
conv2d_model = nn.Conv2d(64, 64, kernel_size=3, stride=1,padding=1, groups=1, bias=False, dilation=1)
conv2d_model.load_state_dict(state_dict)
test_out = conv2d_model(torch.from_numpy(input).unsqueeze(0))
@morgolock morgolock self-assigned this Oct 30, 2023
@morgolock morgolock added this to the v24.02 milestone Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants