针对于模型参数数量的统计(.pth文件)
import torch
# Load the model
content = torch.load('xxxx.pth')
model_state_dict = content['model']
# Initialize a variable to count parameters
total_params = 0
# Iterate over the parameters in the model
for param in model_state_dict.values():
total_params += param.numel()
# Print the total number of parameters
print(f'Total number of parameters in the model: {total_params}')