本文整理汇总了Python中theano.tensor.le方法的典型用法代码示例。如果您正苦于以下问题:Python tensor.le方法的具体用法?Python tensor.le怎么用?Python tensor.le使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类theano.tensor
的用法示例。
在下文中一共展示了tensor.le方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_elemwise_comparaison_cast
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def test_elemwise_comparaison_cast():
"""
test if an elemwise comparaison followed by a cast to float32 are
pushed to gpu.
"""
a = tensor.fmatrix()
b = tensor.fmatrix()
av = theano._asarray(numpy.random.rand(4, 4), dtype='float32')
bv = numpy.ones((4, 4), dtype='float32')
for g, ans in [(tensor.lt, av < bv), (tensor.gt, av > bv),
(tensor.le, av <= bv), (tensor.ge, av >= bv)]:
f = pfunc([a, b], tensor.cast(g(a, b), 'float32'), mode=mode_with_gpu)
out = f(av, bv)
assert numpy.all(out == ans)
assert any([isinstance(node.op, cuda.GpuElemwise)
for node in f.maker.fgraph.toposort()])
示例2: gate_layer
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def gate_layer(tparams, X_word, X_char, options, prefix, pretrain_mode, activ='lambda x: x', **kwargs):
"""
compute the forward pass for a gate layer
Parameters
----------
tparams : OrderedDict of theano shared variables, {parameter name: value}
X_word : theano 3d tensor, word input, dimensions: (num of time steps, batch size, dim of vector)
X_char : theano 3d tensor, char input, dimensions: (num of time steps, batch size, dim of vector)
options : dictionary, {hyperparameter: value}
prefix : string, layer name
pretrain_mode : theano shared scalar, 0. = word only, 1. = char only, 2. = word & char
activ : string, activation function: 'liner', 'tanh', or 'rectifier'
Returns
-------
X : theano 3d tensor, final vector, dimensions: (num of time steps, batch size, dim of vector)
"""
# compute gating values, Eq.(3)
G = tensor.nnet.sigmoid(tensor.dot(X_word, tparams[p_name(prefix, 'v')]) + tparams[p_name(prefix, 'b')][0])
X = ifelse(tensor.le(pretrain_mode, numpy.float32(1.)),
ifelse(tensor.eq(pretrain_mode, numpy.float32(0.)), X_word, X_char),
G[:, :, None] * X_char + (1. - G)[:, :, None] * X_word)
return eval(activ)(X)
示例3: concat_layer
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def concat_layer(tparams, X_word, X_char, options, prefix, pretrain_mode, activ='lambda x: x', **kwargs):
"""
compute the forward pass for a concat layer
Parameters
----------
tparams : OrderedDict of theano shared variables, {parameter name: value}
X_word : theano 3d tensor, word input, dimensions: (num of time steps, batch size, dim of vector)
X_char : theano 3d tensor, char input, dimensions: (num of time steps, batch size, dim of vector)
options : dictionary, {hyperparameter: value}
prefix : string, layer name
pretrain_mode : theano shared scalar, 0. = word only, 1. = char only, 2. = word & char
activ : string, activation function: 'liner', 'tanh', or 'rectifier'
Returns
-------
X : theano 3d tensor, final vector, dimensions: (num of time steps, batch size, dim of vector)
"""
X = ifelse(tensor.le(pretrain_mode, numpy.float32(1.)),
ifelse(tensor.eq(pretrain_mode, numpy.float32(0.)), X_word, X_char),
tensor.dot(tensor.concatenate([X_word, X_char], axis=2), tparams[p_name(prefix, 'W')]) + tparams[p_name(prefix, 'b')])
return eval(activ)(X)
示例4: flux
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def flux(self, xo, yo, zo, ro, u):
"""Compute the light curve."""
# Initialize flat light curve
flux = tt.ones_like(xo)
# Compute the occultation mask
b = tt.sqrt(xo ** 2 + yo ** 2)
b_occ = tt.invert(tt.ge(b, 1.0 + ro) | tt.le(zo, 0.0) | tt.eq(ro, 0.0))
i_occ = tt.arange(b.size)[b_occ]
# Get the Agol `c` coefficients
c = self._get_cl(u)
if self.udeg == 0:
c_norm = c / (np.pi * c[0])
else:
c_norm = c / (np.pi * (c[0] + 2 * c[1] / 3))
# Compute the occultation flux
los = zo[i_occ]
r = ro * tt.ones_like(los)
flux = tt.set_subtensor(
flux[i_occ], self._limbdark(c_norm, b[i_occ], r, los)[0]
)
return flux
示例5: lesser_equal
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def lesser_equal(x, y):
return T.le(x, y)
示例6: less_equal
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def less_equal(x, y):
return T.le(x, y)
示例7: __init__
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def __init__(self, input, sigma=20.0, window_radius=60):
self.input = input
self.sigma = theano.shared(value=np.array(sigma, dtype=theano.config.floatX), name='sigma')
apply_blur = T.gt(self.sigma, 0.0)
no_blur = T.le(self.sigma, 0.0)
self.output = ifelse(no_blur, input, gaussian_filter(input.dimshuffle('x', 0, 1), self.sigma, window_radius)[0, :, :])
self.params = [self.sigma]
示例8: basisf
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def basisf(self, x, s, e):
cpstart = T.le(s, x);
cpend = T.gt(e, x);
if self.order == 1:
return 0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend);
else:
return 0 * (1 - cpstart) + 0.5 * (x - s)**2 * cpstart * cpend + ((e - s) * (x - e) + 0.5 * (e - s)**2) * (1 - cpend);
示例9: get_output_for
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def get_output_for(self, input, **kwargs):
if self.tied_feamap:
return input * T.gt(input, 0) + input * T.le(input, 0) \
* T.shape_padleft(T.shape_padright(self.W[seg], n_ones = len(input_dim) - 2));
else:
return input * T.gt(input, 0) + input * T.le(input, 0) \
* T.shape_padleft(self.W);
示例10: basisf
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def basisf(self, x, s, e):
cpstart = T.le(s, x);
cpend = T.gt(e, x);
return 0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend);
示例11: get_output_for
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def get_output_for(self, input, **kwargs):
return input * T.gt(input, 0) + input * T.le(input, 0) * T.shape_padleft(self.W, n_ones=1);
示例12: basisf
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def basisf(self, x, s, e):
cpstart = T.le(s, x);
cpend = T.gt(e, x);
return 0 * (1 - cpstart) + 0.5 * (x - s)**2 * cpstart * cpend + ((e - s) * (x - e) + 0.5 * (e - s)**2) * (1 - cpend);
示例13: basisf
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def basisf(self, x, start, end):
ab_start = T.le(start, x);
lt_end = T.gt(end, x);
return 0 * (1 - ab_start) + (x - start) * ab_start * lt_end + (end - start) * (1 - lt_end);