How to calculate the number of parameters of an LSTM network?

后端 未结 6 539
情歌与酒
情歌与酒 2020-12-04 20:37

Is there a way to calculate the total number of parameters in a LSTM network.

I have found a example but I\'m unsure of how correct this is or If I have understood i

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 21:01

    Formula expanding for @JohnStrong :

    4 means we have different weight and bias variables for 3 gates (read / write / froget) and - 4-th - for the cell state (within same hidden state). (These mentioned are shared among timesteps along particular hidden state vector)

    4 * lstm_hidden_state_size * (lstm_inputs_size + bias_variable + lstm_outputs_size) 
    

    as LSTM output (y) is h (hidden state) by approach, so, without an extra projection, for LSTM outputs we have :

    lstm_hidden_state_size = lstm_outputs_size 
    

    let's say it's d :

    d = lstm_hidden_state_size = lstm_outputs_size 
    

    Then

    params = 4 * d * ((lstm_inputs_size + 1) + d) = 4 * ((lstm_inputs_size + 1) * d + d^2)
    

提交回复
热议问题