s="va">x</span>
<span class="op">}</span>
<span class="va">sess</span><span class="op">$</span><span class="fu">run</span><span class="op">(</span><span class="fu">stop_if_negative</span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span>
<span class="co">#&gt; [1] -1</span></code></pre></div>
<p>There are two straight forward solutions to this. One is to wrap the block of code in an <code>tf.function()</code></p>
<div class="sourceCode" id="cb3"><pre class="