vim test.py
import theano from theano import tensor ##declare two symbolic floating-point scalars a = tensor.dscalar() b = tensor.dscalar() ##create a simple expression c = a + b ##convert the expression into a callable object that takes (a,b) ##values as input and computes a value for c f = theano.function([a,b], c) ##bind 1.5 to ‘a’, 2.5 to ‘b’, and evaluate ‘c’ assert 4.0 == f(1.5, 2.5)
python3 test.py
运行的示例不提供任何输出,则证明结论1.5+2.5=4.0是真实的。
vim test2.py
import theano from theano import tensor ##declare two symbolic floating-point scalars a = tensor.dscalar() b = tensor.dscalar() ##create a simple expression c = a + b ##convert the expression into a callable object that takes (a,b) ##values as input and computes a value for c f = theano.function([a,b], c) ##bind 1.5 to ‘a’, 2.5 to ‘b’, and evaluate ‘c’ assert 4.5== f(1.5, 2.5)
python3 test2.py
运行的示例将会报错,证明结论1.5+2.5=4.5是错误的。