GRUCell

    门控循环单元(Gated Recurrent Unit)。通过对 fluid.contrib.layers.rnn_impl.BasicGRUUnit 包装,来让它可以应用于RNNCell。

    公式如下:

    更多细节可以参考

    参数:

    • hidden_size (int) - GRUCell中的隐藏层大小。

    • param_attr (ParamAttr,可选) - 指定权重参数属性的对象。默认值为None,表示使用默认的权重参数属性。具体用法请参见 ParamAttr

    • gate_activation (function,可选) -

      GRUCell - 图1

      的激活函数。 默认值为 fluid.layers.sigmoid

    • activation (function,可选) -

      的激活函数。 默认值为 fluid.layers.tanh

    • name (string,可选) - 用于标识参数和偏差的名称域。

    返回:GRUCell类的实例对象。

    示例代码

    ( inputs, states )

    执行GRU的计算。

    参数:

    • input (Variable) - 输入,形状为

      GRUCell - 图2

      的tensor,对应于公式中的

      。数据类型应为float32。

    返回:一个元组 (outputs, new_states) ,其中 outputsnew_states 是同一个tensor,其形状为

    GRUCell - 图3

    ,数据类型和 的数据类型相同,对应于公式中的

    返回类型:tuple

    state_shape ( )

    GRUCell的 state_shape 是形状

    GRUCell - 图4

    (batch大小为-1,自动插入到形状中),对应于

    的形状。

    参数:无。

    返回类型:Variable