def __init__(self, input_width, state_width, learning_rate): self.input_width = input_width self.state_width = state_width self.learning_rate = learning_rate # 门的激活函数 self.gate_activator = SigmoidActivator() # 输出的激活函数 self.output_activator = TanhActivator() # 当前时刻初始化为t0 self.times = 0 # 各个时刻的单元状态向量c self.c_list = self.init_state_vec() # 各个时刻的输出向量h self.h_list = self.init_state_vec() # 各个时刻的遗忘门f self.f_list = self.init_state_vec() # 各个时刻的输入门i self.i_list = self.init_state_vec() # 各个时刻的输出门o self.o_list = self.init_state_vec() # 各个时刻的即时状态c~ self.ct_list = self.init_state_vec() # 遗忘门权重矩阵Wfh, Wfx, 偏置项bf self.Wfh, self.Wfx, self.bf = (self.init_weight_mat()) # 输入门权重矩阵Wfh, Wfx, 偏置项bf self.Wih, self.Wix, self.bi = (self.init_weight_mat()) # 输出门权重矩阵Wfh, Wfx, 偏置项bf self.Woh, self.Wox, self.bo = (self.init_weight_mat()) # 单元状态权重矩阵Wfh, Wfx, 偏置项bf self.Wch, self.Wcx, self.bc = (self.init_weight_mat())
def __init__(self, input_width, state_width, learning_rate): self.input_width = input_width self.state_width = state_width self.learning_rate = learning_rate self.gate_activator = SigmoidActivator() self.output_activator = TanhActivator() self.times = 0 self.c_list = self.init_state_vec() self.h_list = self.init_state_vec() self.f_list = self.init_state_vec() self.i_list = self.init_state_vec() self.o_list = self.init_state_vec() self.ct_list = self.init_state_vec() self.Wfh, self.Wfx, self.bf = (self.init_weight_mat()) self.Wih, self.Wix, self.bi = (self.init_weight_mat()) self.Woh, self.Wox, self.bo = (self.init_weight_mat()) self.Wch, self.Wcx, self.bc = (self.init_weight_mat())
def __init__(self, input_width, state_width, output_width, learning_rate, penaltyL2, momentum): self.input_width = input_width self.state_width = state_width self.output_width= output_width self.learning_rate = learning_rate self.penaltyL2 = penaltyL2 self.momentum = momentum # 门的激活函数 self.gate_activator = SigmoidActivator() # 输出的激活函数 self.output_activator = TanhActivator() self.class_activator = SoftmaxActivator() # 遗忘门权重矩阵Wfh, Wfx, 偏置项bf self.Wfh, self.Wfx, self.bf, self.vWfh, self.vWfx, self.vbf =(self.init_weight_mat(0)) # 输入门权重矩阵Wfh, Wfx, 偏置项bf self.Wih, self.Wix, self.bi, self.vWih, self.vWix, self.vbi =(self.init_weight_mat(0)) # 输出门权重矩阵Wfh, Wfx, 偏置项bf self.Woh, self.Wox, self.bo, self.vWoh, self.vWox, self.vbo =(self.init_weight_mat(0)) # 单元状态权重矩阵Wfh, Wfx, 偏置项bf self.Wch, self.Wcx, self.bc, self.vWch, self.vWcx, self.vbc =(self.init_weight_mat(0)) # 下一层权重Wy, 偏值by self.Wy, self.by, self.vWy, self.vby =(self.init_weight_mat(1))