tf.nn.static_bidirectional_rnn ; tf.contrib.rnn.static_bidirectional_rnn 讲解

tf.nn.static_bidirectional_rnn h 和tf.contrib.rnn.static_bidirectional_rnn是一样的

tf.nn.static_bidirectional_rnn

别名:
tf.contrib.rnn.static_bidirectional_rnn
tf.nn.static_bidirectional_rnn

tf.nn.static_bidirectional_rnn(
    cell_fw,
    cell_bw,
    inputs,
    initial_state_fw=None,
    initial_state_bw=None,
    dtype=None,
    sequence_length=None,
    scope=None
)
'''
Args:
	cell_fw: An instance of RNNCell, to be used for forward direction.
	cell_bw: An instance of RNNCell, to be used for backward direction.
	inputs: A length T list of inputs, each a tensor of shape [batch_size, input_size], or a nested tuple of such elements.
	initial_state_fw: (optional) An initial state for the forward RNN. This must be a tensor of appropriate type and shape [batch_size, cell_fw.state_size]. If cell_fw.state_size is a tuple, this should be a tuple of tensors having shapes [batch_size, s] for s in cell_fw.state_size.
	initial_state_bw: (optional) Same as for initial_state_fw, but using the corresponding properties of cell_bw.
	dtype: (optional) The data type for the initial state. Required if either of the initial states are not provided.
	sequence_length: (optional) An int32/int64 vector, size [batch_size], containing the actual lengths for each of the sequences.
	scope: VariableScope for the created subgraph; defaults to "bidirectional_rnn"
Returns:
	A tuple (outputs, output_state_fw, output_state_bw) where: outputs is a length T list of outputs (one for each input), which are depth-concatenated forward and backward outputs. output_state_fw is the final state of the forward rnn. output_state_bw is the final state of the backward rnn.
	'''
参数说明

cell_fw: An instance of RNNCell, 前向RNNCell 实例
cell_bw: An instance of RNNCell, 反向RNNCell实例
inputs: 输入,是一个长度为 T列表, 每个元素是一个 a tensor(shape [batch_size, input_size])
initial_state_fw: (可选的)前向RNN的初始状态。这必须是类型和形状都满足的tensor([batch_size,cell_fw.state_size])。如果cell_fw.state_size是一个元组,那么它应该也是一个张量元组,元组的每个元素的shape为 [batch_size,s] for s in cell_fw.state_size
**initial_state_bw:**和initial_state_fw要求一样
sequence_length: 可选)int32/int64类型的向量大小为 [batch_size],包含每个序列的实际长度。

返回
一个元组:(outputs,output_state_fw,output_state_bw)
**outputs:**是长度T的list(每个时间步骤对应一个),这些大小为[batch_size,2*hidden_units],这里不理解的请看下面这个图
**output_state_fw:**是正向rnn的最后state(c,h)
**output_state_bw:**是向后rnn的最后state(c,h)

双向RNN

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值