本文整理汇总了Python中theano.tensor.true_div方法的典型用法代码示例。如果您正苦于以下问题:Python tensor.true_div方法的具体用法?Python tensor.true_div怎么用?Python tensor.true_div使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类theano.tensor
的用法示例。
在下文中一共展示了tensor.true_div方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fit
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import true_div [as 别名]
def fit(self, weights, o_error, tpo ):
gradients = T.grad(o_error ,weights)
updates = []
for c, v, w, g in zip(self.t_cache, self.t_velocity, weights,gradients):
new_velocity = T.sub( T.mul(tpo["momentum_rate"], v) , T.mul(tpo["learn_rate"], g) )
new_cache = T.add( T.mul(tpo["decay_rate"] , c) , T.mul(T.sub( 1, tpo["decay_rate"]) , T.sqr(g)))
new_weights = T.sub(T.add(w , new_velocity) , T.true_div( T.mul(g,tpo["learn_rate"]) , T.sqrt(T.add(new_cache,0.1**8))))
updates.append((w, new_weights))
updates.append((v, new_velocity))
updates.append((c, new_cache))
return updates
###### Nesterov momentum
########################################
示例2: avg_pool
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import true_div [as 别名]
def avg_pool(input_layer, **kwargs):
# hack to work around https://github.com/Theano/Theano/issues/3776
norm = nn.layers.ExpressionLayer(input_layer, lambda X: T.ones_like(X))
norm = nn.layers.Pool2DLayer(norm, mode='average_inc_pad', **kwargs)
l = nn.layers.Pool2DLayer(input_layer, mode='average_inc_pad', **kwargs)
l = nn.layers.ElemwiseMergeLayer([l, norm], T.true_div)
return l
示例3: SlopeLin
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import true_div [as 别名]
def SlopeLin(slope):
"""
Linear unit with different slopes
:param slope: slope of negative quadrant
:return: x if x > 0 else x/slope
"""
import theano.tensor as T
def inner(x):
return T.switch(T.gt(x, 0), x, T.true_div(x, slope))
return inner
示例4: SlopeLin2
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import true_div [as 别名]
def SlopeLin2(x, slope):
"""
Linear unit with different slopes
:param slope: slope of negative quadrant
:return: x if x > 0 else x/slope
"""
import theano.tensor as T
return T.switch(T.gt(x, 0), x, T.true_div(x, slope))
示例5: get_output_for
# 需要导入模块: from theano import tensor [as 别名]
# 或者: from theano.tensor import true_div [as 别名]
def get_output_for(self, inputs, deterministic=False, **kwargs):
alpha,beta = inputs
# return 2*T.true_div(alpha,T.add(alpha,beta)+1e-8)-1
return 2*(alpha/(alpha+beta+1e-8))-1
# Convenience Function to produce a residual pre-activation MDCL block