baldassarre.fe:

def count_parameters(model):
return sum(p.numel() for p in model.parameters() if p.requires_grad)


Provided the models are similar in keras and pytorch, the number of trainable parameters returned are different in pytorch and keras.
import torch
import torchvision
from torch import nn
from torchvision import models
a= models.resnet50(pretrained=False)
a.fc = nn.Linear(512,2)
count = count_parameters(a)
print (count)
23509058
Now in keras
import keras.applications.resnet50 as resnet
model =resnet.ResNet50(include_top=True, weights=None, input_tensor=None, input_shape=None, pooling=None, classes=2)
print model.summary()
Total params: 23,591,810
Trainable params: 23,538,690
Non-trainable params: 53,120
Any reasons why this difference in numbers pop up?