<p dir="auto">There are many methods that expect a list or a tensor specifying a shape as argument. It is often the case that I want to pass an argument such as shape=[t1, v2] where t1 is a tensor with shape = TensorShape([]) and v2 is a value. This is currently not possible in many (maybe all) methods.</p>
<p dir="auto">My current work around is the following.<br>
1- convert v2 to a tensor t2 with tf.convert_to_tensor<br>
2- use t1 = tf.expand_dims(0, t1) and t2 = tf.expand_dims(0, t2) to add a dimension of size 1 to the tensors<br>
3- pass the argument as shape=tf.concat(0, [t1, t2])</p>
<p dir="auto">Am I missing a simpler way to accomplish that? Is it a good idea to add a feature that allows passing mixture of tensors and values inside a list as argument?</p>
<p dir="auto">Edit: I just found out that the method tf.pack allows lists with tensors and values as argument. But the method tf.truncated_normal for instance, doesn't allow.<br>
I also realized that I can use tf.pack to replace the steps (1,2,3) above. But it still would be nice if all methods had the same behaviour.</p>
<p dir="auto">I'd like to do things such as the following:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; tf.convert_to_tensor([tf.constant(1), 2])
&gt;&gt;&gt; tf.slice(..., [0, 1, some_tensor], ...)"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">tf</span>.<span class="pl-en">convert_to_tensor</span>([<span class="pl-s1">tf</span>.<span class="pl-en">constant</span>(<span class="pl-c1">1</span>), <span class="pl-c1">2</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">tf</span>.<span class="pl-en">slice</span>(..., [<span class="pl-c1">0</span>, <span class="pl-c1">1</span>, <span class="pl-s1">some_tensor</span>], ...)</pre></div>
<p dir="auto">Currently both of these raise exceptions. The alternative is to use a combination of <code class="notranslate">tf.expand_dims</code> and <code class="notranslate">tf.concat</code>, which is a bit unwieldy.</p>