TensorFlow - Pad unknown size tensor to a specific size? : <p>Is there a way to pad a tensor of variable size to a given shape with a specific pad value? For example given the tensors:</p>

<pre><code>[[1, 2],
 [3, 4]]
</code></pre>

<p>and </p>

<pre><code>[[1, 2, 3],
 [4, 5, 6]]
</code></pre>

<p>Is there a way to have a generic operation which would take either and pad them with a value (say, to shape <code>[2, 4]</code> with value <code>-1</code>) to result in:</p>

<pre><code>[[1, 2, -1, -1],
 [3, 4, -1, -1]]
</code></pre>

<p>and</p>

<pre><code>[[1, 2, 3, -1],
 [4, 5, 6, -1]]
</code></pre>

<p>respectively? My reasoning (in case there is a better solution) is that I have examples from a TFRecords file, part of which has a variable length. For processing, a static length makes them easier to work with.</p>
