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 20:57

    image via this post

    num_params = [(num_units + input_dim + 1) * num_units] * 4
    

    num_units + input_dim: concat [h(t-1), x(t)]

    + 1: bias

    * 4: there are 4 neural network layers (yellow box) {W_forget, W_input, W_output, W_cell}

    model.add(LSTM(units=256, input_dim=4096, input_length=16))
    

    [(256 + 4096 + 1) * 256] * 4 = 4457472

    PS: num_units = num_hidden_units = output_dims

提交回复
热议问题