tensorflow 获取模型所有参数总和数量的方法
实例如下所示:
fromfunctoolsimportreduce fromoperatorimportmul defget_num_params(): num_params=0 forvariableintf.trainable_variables(): shape=variable.get_shape() num_params+=reduce(mul,[dim.valuefordiminshape],1) returnnum_params
以上这篇tensorflow获取模型所有参数总和数量的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。