Arjun Mohan
Arjun Mohan

Reputation: 63

Does tf.strided_slice have a default stride of 1?

I'm trying to replicate the Tensorflow tutorial for LSTM, and in reader.py there's a function called ptb_producer which produces the batches.

In that there's this:

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])

Now on the API page for the function tf.strided_slice, it says the parameter strides has a default value of None. However, as you can see, there is no parameter for strides passed here. Meaning the default value will be used. Does this mean it takes a stride of 1 by default?

Upvotes: 0

Views: 140

Answers (1)

gdelab
gdelab

Reputation: 6220

Yes, the default stride is 1. But with the newer TF versions it's better to write it this way:

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]

Upvotes: 2

Related Questions