Python theano.tensor 模块,power() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用theano.tensor.power()

项目:structured-output-ae    作者:sbelharbi    | 项目源码 | 文件源码
def get_eval_fn(model, in3D=False, use_dice=False):
    """Compile the evaluation function of the model."""
    if use_dice:
        insec = T.sum(model.trg * model.output, axis=1)
        tmp = 1 - 2.0 * insec/(T.sum(model.trg, axis=1) + T.sum(model.output,
                               axis=1))
        error = T.mean(tmp)
    else:
        error = T.mean(T.mean(T.power(model.output - model.trg, 2), axis=1))
    if in3D:
        x = T.tensor4('x')
    else:
        x = T.fmatrix("x")
    y = T.fmatrix("y")

    theano_arg_vl = [x, y]
    output_fn_vl = [error, model.output]

    eval_fn = theano.function(
        theano_arg_vl, output_fn_vl,
        givens={model.x: x,
                model.trg: y})

    return eval_fn
项目:pyextremelm    作者:tobifinn    | 项目源码 | 文件源码
def _generate_conv(self):
        input = T.tensor4(name='input')
        if self.pooling == 'squareroot':
            conv_out = Pool.pool_2d(
                T.power(input,2),
                ds=(self.spatial[0], self.spatial[1]),
                ignore_border=self.ignore_border,
                mode='sum',
                padding=self.pad,
                st=None if self.stride is None else (self.stride, self.stride))
            conv_out = T.sqrt(conv_out)
        else:
            conv_out = Pool.pool_2d(
                input,
                ds=(self.spatial[0], self.spatial[1]),
                ignore_border=self.ignore_border,
                mode=self.pooling,
                padding=self.pad,
                st=None if self.stride is None else (self.stride, self.stride))
        if self.activation_fct is None:
            output = conv_out
        else:
            output = self.activation_fct(conv_out)
        self.conv = theano.function([input], output)
项目:NNBuilder    作者:aeloyq    | 项目源码 | 文件源码
def pow(self, l, r):
            return T.power(l, r)
项目:eqnet    作者:mast-group    | 项目源码 | 文件源码
def __get_loss(self, use_dropout, iteration_number=0):
        node_encoding1, _, extra_loss1 = self.__rnn.get_encoding(use_dropout, iteration_number)
        node_encoding1 /= node_encoding1.norm(2)

        copy_rnn = self.__rnn.copy_full()
        node_encoding2, _, extra_loss2 = copy_rnn.get_encoding(use_dropout, iteration_number)
        node_encoding2 /= node_encoding2.norm(2)

        distance = (node_encoding1 - node_encoding2).norm(2)

        are_non_equivalent = self.__rnn.get_input_variables().eq_symbol - copy_rnn.get_input_variables().eq_symbol

        margin = self.__hyperparameters['dissimilar_margin']
        siamese_loss = -T.power(T.switch(are_non_equivalent, T.nnet.relu(margin - distance), distance), 2)
        return siamese_loss + extra_loss1 + extra_loss2, copy_rnn
项目:Hat    作者:qiuqiangkong    | 项目源码 | 文件源码
def power(x, a):
    return T.power(x, a)