擅长:python、mysql、java
<p>我相信你代码中的错误在:<code>correct_prediction = tf.equal( tf.round( pred ), tf.round( y_ ) )</code>。</p>
<p><code>pred</code>应为<strong>未标度登录</strong>(即没有最终乙状结肠)。</p>
<p>在这里,您需要比较<code>sigmoid(pred)</code>和<code>y_</code>的输出(两者都在间隔<code>[0, 1]</code>)以便您必须编写:</p>
<pre class="lang-py prettyprint-override"><code>correct_prediction = tf.equal(tf.round(tf.nn.sigmoid(pred)), tf.round(y_))
</code></pre>
<hr/>
<p>然后计算:</p>
<ul>
<li>所有标签的平均准确度:</li>
</ul>
<pre class="lang-py prettyprint-override"><code>accuracy1 = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
</code></pre>
<ul>
<li>所有标签需要正确的准确度:</li>
</ul>
<pre class="lang-py prettyprint-override"><code>all_labels_true = tf.reduce_min(tf.cast(correct_prediction), tf.float32), 1)
accuracy2 = tf.reduce_mean(all_labels_true)
</code></pre>