I have a similar question, this one TensorFlow - Pad unknown size tensor to a specific size?. My question is more difficult though, and I didn't find any solutions can solve my question. My question is that what if the given unknown tensor have different sizes in the last dimension and I want to pad them to the same fix length, how can I do that? For example, suppose the given tensor is
[[1],
[1, 2],
[1, 2, 3]]
I want to pad them such that I can get
[[1, 0, 0, 0],
[1, 2, 0, 0],
[1, 2, 3, 0]]
The solutions in the original post all assume the last dimension have the same length. Any ideas on how to solve this problem? I am not even sure if tf.pad()
is the right function to achieve this...