簡體   English   中英

如何理解張量流的Slice函數?

[英]How to understand the tensorflow's Slice function?

最近,我從tensorflow的教程中學習了有關RNN的代碼。部分代碼如下,而更多信息在https://www.tensorflow.org/tutorials/recurrent

outputs = []
    state = self._initial_state
    with tf.variable_scope("RNN"):
      for time_step in range(num_steps):
        if time_step > 0: tf.get_variable_scope().reuse_variables()
        (cell_output, state) = cell(inputs[:, time_step, :], state)#here!
        outputs.append(cell_output)

我只是無法理解inputs[:, time_step, :]是如何工作的,例如,這些Args是什么意思? 您的回答將不勝感激。非常感謝!

如果input的形狀為[d1, d2, d3] ,則time_stepd2以下的自然整數,並且

output = inputs[:, time_step, :]

然后輸出的是形狀為[d1, 1, d3]的矩陣,使得

output[i, 0, j] = input[i, time_step, j]

它基本上提取括號中給定索引的輸入元素, “:”表示“所有維度上的所有元素

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM