代码1:(if else判断结构)
import theano
from theano import tensor
from theano.ifelse import ifelse
x = tensor.fscalar('x')
y = tensor.fscalar('y')
z = ifelse(x>0, 2*y, 3*y) # x>0的返回值是int8类型
f = theano.function([x,y], z, allow_input_downcast=True)
print( f(1.1, 2.2) )
print( f(-1.1, 2.2) )
运行结果:
代码2:(循环:scan)
参考:
https://zhuanlan.zhihu.com/p/24282760
标签:tensor,框架,示例,代码,grandfather,ifelse,import,theano From: https://www.cnblogs.com/devilmaycry812839668/p/18013729