Skip to content

Instantly share code, notes, and snippets.

@arunm8489
Created June 4, 2020 07:35
Show Gist options
  • Save arunm8489/98c04c78cb6137335cd7e8fbb904e4ee to your computer and use it in GitHub Desktop.
Save arunm8489/98c04c78cb6137335cd7e8fbb904e4ee to your computer and use it in GitHub Desktop.
#Let us load the weights for the Convolutional layers
# we are loading weights as common beacuse when batchnormalization is present there is no bias for conv layer
num_weights = conv.weight.numel()
#Do the same as above for weights
conv_weights = torch.from_numpy(weights[ptr:ptr+num_weights])
ptr = ptr + num_weights
conv_weights = conv_weights.view_as(conv.weight.data)
conv.weight.data.copy_(conv_weights)
# Note: we dont have bias for conv when batch normalization is there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment