GRUCell
类keras.layers.GRUCell(
units,
activation="tanh",
recurrent_activation="sigmoid",
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,
reset_after=True,
seed=None,
**kwargs
)
GRU 层的单元类。
此类处理整个时间序列输入中的一个步骤,而 keras.layer.GRU
处理整个序列。
参数
tanh
)。如果传递 None,则不应用激活函数(即“线性”激活:a(x) = x
)。sigmoid
)。如果传递 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))
>>> rnn = keras.layers.RNN(keras.layers.GRUCell(4))
>>> output = rnn(inputs)
>>> output.shape
(32, 4)
>>> rnn = keras.layers.RNN(
... keras.layers.GRUCell(4),
... return_sequences=True,
... return_state=True)
>>> whole_sequence_output, final_state = rnn(inputs)
>>> whole_sequence_output.shape
(32, 10, 4)
>>> final_state.shape
(32, 4)