当前位置: 首页>>代码示例>>Python>>正文


Python tensor.le方法代码示例

本文整理汇总了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()]) 
开发者ID:muhanzhang,项目名称:D-VAE,代码行数:22,代码来源:test_basic_ops.py

示例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) 
开发者ID:nyu-dl,项目名称:gated_word_char_rlm,代码行数:27,代码来源:layers.py

示例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) 
开发者ID:nyu-dl,项目名称:gated_word_char_rlm,代码行数:25,代码来源:layers.py

示例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 
开发者ID:rodluger,项目名称:starry,代码行数:26,代码来源:core.py

示例5: lesser_equal

# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def lesser_equal(x, y):
    return T.le(x, y) 
开发者ID:lingluodlut,项目名称:Att-ChemdNER,代码行数:4,代码来源:theano_backend.py

示例6: less_equal

# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import le [as 别名]
def less_equal(x, y):
    return T.le(x, y) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:4,代码来源:theano_backend.py

示例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] 
开发者ID:matthias-k,项目名称:pysaliency,代码行数:9,代码来源:theano_utils.py

示例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); 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:9,代码来源:smthact_new.py

示例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); 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:9,代码来源:smthact_new.py

示例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); 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:6,代码来源:smthact.py

示例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); 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:4,代码来源:smthact.py

示例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); 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:6,代码来源:smthact.py

示例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); 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:6,代码来源:smthact.py


注:本文中的theano.tensor.le方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。