zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然TensorFlow2教程:全连接层

    out = f(X@W + b)
    out = relut(X@W + b)

     

     

    import tensorflow as tf
    
    x = tf.random.normal([4, 784])
    net = tf.keras.layers.Dense(512)
    out = net(x)
    out.shape
    net.kernel.shape, net.bias.shape
    net = tf.keras.layers.Dense(10)
    try:
        net.bias
    except Exception as e:
        print(e)
    net.build(input_shape=(None, 4))
    net.kernel.shape, net.bias.shape
    net.build(input_shape=(None, 20))
    net.kernel.shape, net.bias.shape
    net.build(input_shape=(2, 4))
    net.kernel
    from tensorflow import keras
    
    x = tf.random.normal([2, 3])
    model = keras.Sequential([
        keras.layers.Dense(2, activation='relu'),
        keras.layers.Dense(2, activation='relu'),
        keras.layers.Dense(2)
    ])
    model.build(input_shape=[None, 3])
    model.summary()
    # [w1,b1,w2,b2,w3,b3]
    for p in model.trainable_variables:
        print(p.name, p.shape)
  • 相关阅读:
    [C语言
    [C语言
    [C语言
    [C语言
    [C语言
    [C语言
    [iOS]超详细Apache服务器的配置(10.10系统)
    IOS优秀博客
    「C」 数组、字符串、指针
    103.Binary Tree Zigzag Level Order Traversal(层序遍历)
  • 原文地址:https://www.cnblogs.com/tszr/p/12221455.html
Copyright © 2011-2022 走看看