擅长:python、mysql、java
<p>对于未来的读者:前面的答案非常好。
但是,我发现“tag.test-value”机制对于调试更为有利(请参见<a href="http://deeplearning.net/software/theano/tutorial/debug_faq.html#using-test-values" rel="noreferrer">theano-debug-faq</a>):</p>
<pre><code>from theano import config
from theano import tensor as T
config.compute_test_value = 'raise'
import numpy as np
#define a variable, and use the 'tag.test_value' option:
x = T.matrix('x')
x.tag.test_value = np.random.randint(100,size=(5,5))
#define how y is dependent on x:
y = x*x
#define how some other value (here 'errorCount') depends on y:
errorCount = T.sum(y)
#print the tag.test_value result for debug purposes!
errorCount.tag.test_value
</code></pre>
<p>对我来说,这更有用;例如,检查正确的尺寸等</p>