본문 바로가기

implement_ml_models/RNN

implement_LSTM(output_gate)

입력 데이터 벡터에 가중치 행렬을 곱한 값

은닛 유닛에는 가중치 행렬을 곱한 값을 더하고 편향을 더한다.

이렇게 더한 값에 시그모이드 함수를 취해 출력 게이트를 거친 o 를 구할 수 있다.

  def output_gate(self, input_x, input_h, output):
    activation = Activation()

    w_xo = np.random.rand(output.shape[0], input_x.shape[0])
    w_ho = np.random.rand(output.shape[0], output.shape[1])
    b_o = np.random.rand(output.shape[0],1)
    
    self.w_xo.append(w_xo)
    self.w_ho.append(w_ho)
    self.b_o.append(b_o)

    hidden_input = w_xo@input_x + w_ho@input_x + b_o
    
    return activation.sigmoid_fun(hidden_input)

 

'implement_ml_models > RNN' 카테고리의 다른 글

implement_LSTM(hidden_unit_output)  (0) 2022.12.13
implement_LSTM(cell_state)  (0) 2022.12.13
implement_LSTM(forget_gate)  (0) 2022.12.13
implement_LSTM(input_gate)  (0) 2022.12.13
implement_delta(before_w)(2)  (0) 2022.12.05