Number of parameters for Keras SimpleRNN

后端 未结 3 408
礼貌的吻别
礼貌的吻别 2020-12-11 05:53

I have a simpleRNN like:

model.add(SimpleRNN(10, input_shape=(3, 1)))
model.add(Dense(1, activation=\"linear\"))
         


        
3条回答
  •  青春惊慌失措
    2020-12-11 06:21

    I visualize the SimpleRNN you add, I think the figure can explain a lot.

    SimpleRNN layer, I'm a newbie here, can't post images directly, so you need to click the link.

    From the unrolled version of SimpleRNN layer,it can be seen as a dense layer. And the previous layer is a concatenation of input and the current layer(previous step) itself.

    So the number of parameters of SimpleRNN can be computed as a dense layer:

    num_para = units_pre * units + num_bias

    where:

    units_pre is the sum of input neurons(1 in your settings) and units(see below),

    units is the number of neurons(10 in your settings) in the current layer,

    num_bias is the number of bias term in the current layer, which is the same as the units.

    Plugging in your settings, we achieve the num_para = (1 + 10) * 10 + 10 = 120.

提交回复
热议问题