smile学子吧 关注:8贴子:998
  • 3回复贴,共1

show_all_variables()函数

只看楼主收藏回复



IP属地:广东1楼2018-11-12 16:13回复
    首先,tf.trainable_variables返回的是需要训练的变量列表;
    然后用tensorflow.contrib.slim中的model_analyzer.analyze_vars打印出所有与训练相关的变量信息。


    IP属地:广东2楼2018-11-12 16:15
    回复
      2025-05-15 15:32:22
      广告
      import tensorflow as tf
      import tensorflow.contrib.slim as slim
      x1=tf.Variable(tf.constant(1,shape=[1],dtype=tf.float32),name='x11')
      x2=tf.Variable(tf.constant(2,shape=[1],dtype=tf.float32),name='x22')
      m=tf.train.ExponentialMovingAverage(0.99,5)
      v=tf.trainable_variables()
      for i in v:
      print (i)
      slim.model_analyzer.analyze_vars(v,print_info=True)
      输出:
      <tf.Variable 'x11:0' shape=(1,) dtype=float32_ref>
      <tf.Variable 'x22:0' shape=(1,) dtype=float32_ref>
      ---------
      Variables: name (type shape) [size]
      ---------
      x11:0 (float32_ref 1) [1, bytes: 4]
      x22:0 (float32_ref 1) [1, bytes: 4]
      Total size of variables: 2
      Total bytes of variables: 8


      IP属地:广东3楼2018-11-12 16:16
      回复
        学到了


        IP属地:安徽4楼2019-01-08 20:07
        回复