擅长:python、mysql、java
<p>在python中,可以返回函数的输出列表。所以,我会这样做:</p>
<pre><code>def conv_net(x, weights, biases):
conv1 = conv2d(x, weights['wc1'], biases['bc1'])
conv1 = maxpool2d(conv1, k=2)
conv2 = conv2d(conv1, weights['wc2'], biases['bc2'])
conv2 = maxpool2d(conv2, k=2)
conv3 = conv2d(conv2, weights['wc3'], biases['bc3'])
conv3 = maxpool2d(conv3, k=2)
# Fully connected layer
fc1 = tf.reshape(conv3, [-1, weights['wd1'].get_shape().as_list()[0]])
fc1 = tf.add(tf.matmul(fc1, weights['wd1']), biases['bd1'])
fc1 = tf.nn.relu(fc1)
out = tf.add(tf.matmul(fc1, weights['out']), biases['out'])
return [out,fc1]
</code></pre>
<p>当您想要获得输出时,您可以:</p>
<pre><code>pred, fcn = conv_net(x, weights, biases)
</code></pre>
<p>当您想在会话中看到结果时,请执行以下操作:</p>
<pre><code>fcn_evaluated = sess.run(fcn)
print(fcn_evaluated)
</code></pre>