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)