脚本专栏 
首页 > 脚本专栏 > 浏览文章

tensorflow 获取模型所有参数总和数量的方法

(编辑:jimmy 日期: 2025/11/14 浏览:3 次 )

实例如下所示:

from functools import reduce
from operator import mul

def get_num_params():
 num_params = 0
 for variable in tf.trainable_variables():
  shape = variable.get_shape()
  num_params += reduce(mul, [dim.value for dim in shape], 1)
 return num_params

以上这篇tensorflow 获取模型所有参数总和数量的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

上一篇:Python3.6日志Logging模块简单用法示例
下一篇:Python实现的knn算法示例