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

378人浏览 / 0人评论

实例如下所示:

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 获取模型所有参数总和数量的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

全部评论

晴天下起了小雨
2017-10-01 18:00
很喜欢,果断关注了
wjmyly7336064
2017-10-01 18:00
相当实用,赞美了
橘大佬
2017-10-01 18:00
就是有些细节再到位点就好了…