Here is my codes before:

model = senet.SENet50()
num_ftrs = model.linear.in_features # revising the categories classes
model.linear= nn.Linear(num_ftrs, len(targets))
ct = 0
for name, child in model.named_children():
ct += 1
if ct < 8:
for name2, params in child.named_parameters():
params.requires_grad = False
output = model(img_data)

And it came out the problem :RuntimeError: size mismatch, m1: [8 x 73728], m2: [512 x227]
But now after i change your codes:

from senet import PreActBlock
model =  SENet(PreActBlock, [2,2,2,2])
num_ftrs = model.linear.in_features # revising the categories classes
model.linear= nn.Linear(num_ftrs, 10)
out = model(torch.randn(1, 3, 32, 32))
ct = 0
for name, child in model.named_children(): #frozen 7 layers
ct += 1
if ct < 8:
for name2, params in child.named_parameters():
params.requires_grad = False


for img_data, target in tqdm_notebook(train_loader, desc='Training'):    
    img_data, target = img_data.to(device), target.to(device)
    
    output = model(img_data) #FWD prop 


it came out the same problem as I showed in the last reply.
RuntimeError: size mismatch, m1: [8 x 73728], m2: [512 x 10]
Plus: my dataset is food101 and it has 101 classes.