<p dir="auto">In some applications, we need to repeat Tensors, so hopefully there could be a build-in function tf.repeat which is equivalent to np.repeat.</p>
<p dir="auto">Example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" np.repeat([1, 2, 3], 2)
&gt;&gt; array([1, 1, 2, 2, 3, 3])"><pre class="notranslate"><code class="notranslate"> np.repeat([1, 2, 3], 2)
&gt;&gt; array([1, 1, 2, 2, 3, 3])
</code></pre></div>
<p dir="auto">This is a popular question on StackOverflow:<br>
<a href="http://stackoverflow.com/questions/35361467/tensorflow-numpy-repeat-alternative" rel="nofollow">http://stackoverflow.com/questions/35361467/tensorflow-numpy-repeat-alternative</a></p>
<p dir="auto">But note that the answer so far only works for some use cases (the one presented in the question).</p>
<p dir="auto">The best I could come up with for a general solution uses <code class="notranslate">tf.while_loop</code>, which is pretty verbose (and maybe slower than necessary). I'll add a link to the implementation I wrote for <code class="notranslate">tf.contrib.training.resample_at_rate</code> after the next internal/github sync.</p>