SimpleRNNCell
类keras.layers.SimpleRNNCell(
units,
activation="tanh",
use_bias=True,
kernel_initializer="glorot_uniform",
recurrent_initializer="orthogonal",
bias_initializer="zeros",
kernel_regularizer=None,
recurrent_regularizer=None,
bias_regularizer=None,
kernel_constraint=None,
recurrent_constraint=None,
bias_constraint=None,
dropout=0.0,
recurrent_dropout=0.0,
seed=None,
**kwargs
)
SimpleRNN 的单元类。
此类处理整个时间序列输入中的一个步骤,而 keras.layer.SimpleRNN
处理整个序列。
参数
tanh
)。如果传递 None
,则不应用任何激活函数(即“线性”激活:a(x) = x
)。True
),指示层是否应使用偏置向量。kernel
权重矩阵的初始化器。默认值:"glorot_uniform"
。recurrent_kernel
权重矩阵的初始化器。默认值:"orthogonal"
。"zeros"
。kernel
权重矩阵的正则化函数。默认值:None
。recurrent_kernel
权重矩阵的正则化函数。默认值:None
。None
。kernel
权重矩阵的约束函数。默认值:None
。recurrent_kernel
权重矩阵的约束函数。默认值:None
。None
。调用参数
(batch, features)
。(batch, units)
,它是前一个时间步的状态。dropout
或 recurrent_dropout
时才相关。示例
inputs = np.random.random([32, 10, 8]).astype(np.float32)
rnn = keras.layers.RNN(keras.layers.SimpleRNNCell(4))
output = rnn(inputs) # The output has shape `(32, 4)`.
rnn = keras.layers.RNN(
keras.layers.SimpleRNNCell(4),
return_sequences=True,
return_state=True
)
# whole_sequence_output has shape `(32, 10, 4)`.
# final_state has shape `(32, 4)`.
whole_sequence_output, final_state = rnn(inputs)