本文整理汇总了Python中LogisticRegression.LogisticRegression.regularizer方法的典型用法代码示例。如果您正苦于以下问题:Python LogisticRegression.regularizer方法的具体用法?Python LogisticRegression.regularizer怎么用?Python LogisticRegression.regularizer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogisticRegression.LogisticRegression
的用法示例。
在下文中一共展示了LogisticRegression.regularizer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Hidden
# 需要导入模块: from LogisticRegression import LogisticRegression [as 别名]
# 或者: from LogisticRegression.LogisticRegression import regularizer [as 别名]
m_test_sample = Ts[1].shape[0]
x, y = T.dmatrices('x', 'y')
H = Hidden( x, 784, 50, param_init = ( 'glorot', 'zero' ) , activation_func = T.tanh )
h = H.output( )
L = LogReg( h, 50, 10, param_init = ( 'zero', 'zero' ) )
lam = 0.02 # regularizer
alpha = 0.8 # learning rate/ weight decay
zeta = 0.995 # nestrov momentum
global cost
if lam is None:
cost = L.cost( y )
else:
cost = L.cost( y ) + L.regularizer ( {'weights':lam, 'bias':0.0} ) \
+ lam * H.regularizer_L2( ) + 0.02 * H.regularizer_L1( )
pred = L.predict ( )
gw = T.grad (cost, wrt=L.W)
gb = T.grad (cost, wrt=L.B)
gwh1 = T.grad ( cost, wrt=H.W )
gbh1 = T.grad ( cost, wrt=H.B )
W_shape, B_shape = L.weightShapes()
WH1_shape, BH1_shape = H.weightShapes()
VW = zeros(W_shape)
VB = zeros(B_shape)
VWH1 = zeros(WH1_shape)
VBH1 = zeros(BH1_shape)
train = function( [x,y], [cost, gw, gb, gwh1, gbh1] )