本文整理匯總了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