This function concatenates the sos symbol at the start of any string and removes the last column from a specified bunch of strings using tensorflow. I understand this for most part but I'm still having trouble with the strided_slice function. It takes the beginning and the end point from where we want to slice our vertex but the fourth argument i.e the stride of [1,1]. I don't know what this represents.
Here's the code:
def preprocess_outputs(outputs, words2int, batch_size):
left_side = tf.fill([batch_size, 1], words2int['<SOS>'])
right_side = tf.strided_slice(outputs, [0, 0], [batch_size, -1], [1, 1])
preprocessed_output = tf.concat([left_side, right_side], 1)
return preprocessed_output
Read more here: https://stackoverflow.com/questions/66274285/tensorflow-strided-slice-function
Content Attribution
This content was originally published by Haris Xhan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.