pytorch 模型参数量

# Find total parameters and trainable parameters
total_params = sum(p.numel() for p in model.parameters())
print(f'{total_params:,} total parameters.')
total_trainable_params = sum(
    p.numel() for p in model.parameters() if p.requires_grad)
print(f'{total_trainable_params:,} training parameters.')

pytorch可以直接调用,输出训练参数量和全部参数量

你可能感兴趣的:(pytorch,人工智能,python)