1. 程式人生 > >一直在等待,一直會等待 TensorFlow常見API--4

一直在等待,一直會等待 TensorFlow常見API--4

tf.nn.static_rnn

tf.nn.static_rnn(
    cell,
    inputs,
    initial_state=None,
    dtype=None,
    sequence_length=None,
    scope=None
)

       由RNNCell cell宣告建立遞迴神經網路。初始狀態可以被提供。如果提供了sequence_length vector,將自動進行計算。        輸入引數: cell: RNNCell例項 inputs: A length T list of inputs, each a Tensor of shape [batch_size, input_size], or a nested tuple of such elements. sequence_length:

宣告輸入中每個序列的長度。整形向量,size [batch_size], values in [0, T).        輸出引數: outputs: 長度為T的List,每個元素為一個X對應的輸出結果,或者是每個元素巢狀的元組 state: 最後一個隱狀態

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
)

盜用一張圖用於說明 在這裡插入圖片描述        輸出引數: 輸出結果為元組 (outputs, output_state_fw, output_state_bw) 其中,outputs is a length T list of outputs (one for each input), 長度採用depth-concatenated forward and backward的輸出結果. output_state_fw is the final state of the forward rnn. output_state_bw is the final state of the backward rnn.