Python tf.strided_切片的默认步幅是否为1?
我试图复制,其中有一个名为Python tf.strided_切片的默认步幅是否为1?,python,tensorflow,lstm,Python,Tensorflow,Lstm,我试图复制,其中有一个名为ptb_producer的函数,用于生成批 在这一点上: i = tf.train.range_input_producer(epoch_size, shuffle=False).dequeue() x = tf.strided_slice(data, [0, i * num_steps], [batch_size, (i + 1) * num_steps]) x.set_shape([batch_size, num_steps
ptb_producer
的函数,用于生成批
在这一点上:
i = tf.train.range_input_producer(epoch_size, shuffle=False).dequeue()
x = tf.strided_slice(data, [0, i * num_steps],
[batch_size, (i + 1) * num_steps])
x.set_shape([batch_size, num_steps])
y = tf.strided_slice(data, [0, i * num_steps + 1],
[batch_size, (i + 1) * num_steps + 1])
y.set_shape([batch_size, num_steps])
现在,对于函数
tf.stripped\u slice
,它表示参数strippes
的默认值为None
。但是,正如您所看到的,这里没有传递的步长参数。这意味着将使用默认值。这是否意味着默认步幅为1?是的,默认步幅为1。但对于较新的TF版本,最好这样编写:
x = data[0:batch_size, i * num_steps:(i + 1) * num_steps]
y = data[0:batch_size, i * num_steps + 1:(i + 1) * num_steps + 1]
是,默认步幅为1。但对于较新的TF版本,最好这样编写:
x = data[0:batch_size, i * num_steps:(i + 1) * num_steps]
y = data[0:batch_size, i * num_steps + 1:(i + 1) * num_steps + 1]