目录
- recap
- Perceptron
- Derivative
recap
\(y = XW + b\)
\(y = \sum{x_i}*w_i + b\)
Perceptron
- \(x_i^0\) i表示当成第i个节点
- \(w_{ij}^0\) 表示当层的第i个节点,j表示下一个隐藏层的第j个节点
- \(\sigma\) 表示激活函数后的节点
- E表示error值
- t表示target值
Derivative
- \(E=\frac{1}{2}(O_0^1-t)^2\)
import tensorflow as tf
x = tf.random.normal([1, 3])
w = tf.ones([3, 1])
b = tf.ones([1])
y = tf.constant([1])
with tf.GradientTape() as tape:
tape.watch([w, b])
prob = tf.sigmoid(x @ w + b)
loss = tf.reduce_mean(tf.losses.MSE(y, prob))
grads = tape.gradient(loss, [w, b])
[,
]
grads[0]
grads[1]