RNN
方法一
前向传播
损失函数
注意交叉熵损失计算
反向传播
V V V 的梯度计算:
W W W 的梯度计算:
误差计算:
import numpy as np
class ReluActivator(object):
def forward(self, weighted_input):
#return weighted_input
return max(0, weighted_input)
def backward(self, output):
return 1 if output > 0 else 0
class IdentityActivator(object):
def forward(self, weighted_input):
return weighted_input
def backward(self, output):
return 1
class SigmoidActivator(object)