2017-06-19 102 views
1

近日,笔者从tensorflow.Part代码如下教程在https://www.tensorflow.org/tutorials/recurrent如何理解tensorflow的切片功能?

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) 

了解RNN的代码,而更多的信息,我只是不能说undetstand如何inputs[:, time_step, :]作品,例如,这些Args是什么意思? 您的回答将不胜感激。非常感谢!

回答

0

如果input是形状[d1, d2, d3]的,time_step低于d2的自然数,并且

output = inputs[:, time_step, :] 

然后输出形状的矩阵[d1, 1, d3]使得

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

它基本上提取的元素由括号中给出的指数给出的输入,“:”含义“所有这些都在该维度上”

+1

非常感谢!你让我摆脱困惑。 – chuchienshu

+0

对不起,我只是一个初学者到StackOverFlow,并且我只点击了上拉(没有显示,因为我的名声低于15)。现在,接受。谢谢 – chuchienshu