Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow 试图理解深层RNN权重_Tensorflow_Keras_Deep Learning_Recurrent Neural Network - Fatal编程技术网

Tensorflow 试图理解深层RNN权重

Tensorflow 试图理解深层RNN权重,tensorflow,keras,deep-learning,recurrent-neural-network,Tensorflow,Keras,Deep Learning,Recurrent Neural Network,我试图了解RNN训练的重量。对于具有1层的简单RNN,很容易理解。例如,如果时间步长的输入形状为[50,3],则每个特征需要训练3个权重,加上权重的偏差和输入状态的权重。但我很难理解,随着RNN数量的增加,参数是如何变成12、21、32的。谢谢你的指导 model = Sequential([ SimpleRNN(1, return_sequences = False, input_shape = [50, 3]), # 3 features and 1 per Wx and Wy

我试图了解RNN训练的重量。对于具有1层的简单RNN,很容易理解。例如,如果时间步长的输入形状为[50,3],则每个特征需要训练3个权重,加上权重的偏差和输入状态的权重。但我很难理解,随着RNN数量的增加,参数是如何变成12、21、32的。谢谢你的指导

model = Sequential([
    SimpleRNN(1, return_sequences = False, input_shape = [50, 3]),    # 3 features and 1 per Wx and Wy
    Dense(1) 
])


model.summary()

model2 = Sequential([
    SimpleRNN(2, return_sequences = False, input_shape = [50, 3]),    
    Dense(1) # last do not neeed the return sequencies
])

model2.summary()


model3 = Sequential([
    SimpleRNN(3, return_sequences = False, input_shape = [50, 3]),   
    Dense(1) # last do not neeed the return sequencies
])

model3.summary()


model4 = Sequential([
    SimpleRNN(4, return_sequences = False, input_shape = [50, 3]),  
    Dense(1) # last do not neeed the return sequencies
])
对于您的型号2:

model2=顺序([
SimpleRN(2,返回_序列=False,输入_形状=[50,3]),
密集(1)#最后不需要返回顺序
])
下图显示了其中一个神经元的权重(5个权重),您将有1个偏差。因此每个神经元有6个参数,总参数计数为6*2=12

您的示例的公式为:
h*(3+h)+h


其中,
(3+h)
是每个神经元的权重数,最后一个
h
将偏差添加到参数中

非常感谢,现在这很有意义。每个“神经元”是一个单独的RNN单元,每个处理一个输入,还是每个输入都连接到单个RNN单元的单个输入?我很困惑,网上的大多数解释都漏掉了很多。@Matt我不太明白你的问题,但我希望这能有所帮助:RNN是层而不是单个神经元。例如,在上面的图像中,当前时间步(红色圆圈)内是一层RNN,它获取一层输入(蓝色圆圈)及其以前的状态(灰色圆圈)。实际上,灰色的圆圈不是单独的东西。它们是最后一个时间步中的红色圆圈
Model: "sequential_20"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
simple_rnn_22 (SimpleRNN)    (None, 1)                 5         
_________________________________________________________________
dense_18 (Dense)             (None, 1)                 2         
=================================================================
Total params: 7
Trainable params: 7
Non-trainable params: 0
_________________________________________________________________
Model: "sequential_21"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
simple_rnn_23 (SimpleRNN)    (None, 2)                 12        
_________________________________________________________________
dense_19 (Dense)             (None, 1)                 3         
=================================================================
Total params: 15
Trainable params: 15
Non-trainable params: 0
_________________________________________________________________
Model: "sequential_22"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
simple_rnn_24 (SimpleRNN)    (None, 3)                 21        
_________________________________________________________________
dense_20 (Dense)             (None, 1)                 4         
=================================================================
Total params: 25
Trainable params: 25
Non-trainable params: 0
_________________________________________________________________
Model: "sequential_23"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
simple_rnn_25 (SimpleRNN)    (None, 4)                 32        
_________________________________________________________________
dense_21 (Dense)             (None, 1)                 5         
=================================================================
Total params: 37
Trainable params: 37
Non-trainable params: 0
_________________________________________________________________