zoukankan      html  css  js  c++  java
  • 打印权重与展示权重

    layer1 = tf.layers.dense(inputs=x,
                             units=256,
                             activation=tf.nn.relu,
                             bias_initializer=tf.constant_initializer(0),
                             kernel_initializer=tf.truncated_normal_initializer(stddev=0.01),
                             kernel_regularizer = tf.contrib.layers.l1_regularizer(0.0003),
                             name= 'layer1'
                             )
    with tf.variable_scope("layer1", reuse=True):
    	w = tf.get_variable("kernel")
        b = tf.get_variable("bias")
    	w = w.eval()
        b = b.eval()
    
    

    需要先给网络层定义一个变量空间,然后使用tf.variable_scope获取该变量空间里面的变量。

    通过图片显示权重:

    from PIL import Image
    img = Image.fromarray((w-w.min())/(w.max()-w.min())* 255.0)
    img.show()
    
    
  • 相关阅读:
    关于asp.netCore3.0区域和路由配置
    用Autofac替换.net core 内置容器
    C#Assembly详解
    MongoDB
    Python
    Python,正则表达式
    Python
    Python
    Gevent和猴子补丁
    Django
  • 原文地址:https://www.cnblogs.com/Chen-rd/p/9171847.html
Copyright © 2011-2022 走看看