时间:2022-02-22 10:57:46 | 栏目:Python代码 | 点击:次
Pytorch中,变量参数,用numel得到参数数目,累加
def get_parameter_number(net): total_num = sum(p.numel() for p in net.parameters()) trainable_num = sum(p.numel() for p in net.parameters() if p.requires_grad) return {'Total': total_num, 'Trainable': trainable_num}
Keras中,直接使用model的summary函数
model = k_model() model.summary()