def test_correctness():
 model = MLP(layers=[Linear(dim=10, layer_name='linear', irange=1.0), Softmax(n_classes=2, layer_name='softmax', irange=1.0)], batch_size=10, nvis=10)
 cost = LpPenalty(variables=model.get_params(), p=2)
 penalty = cost.expr(model, None)
 penalty_function = theano.function(inputs=[], outputs=penalty)
 p = penalty_function()
 actual_p = 0
 for param in model.get_params():
  actual_p += numpy.sum((param.get_value() ** 2))
 assert numpy.allclose(p, actual_p)

def test_correctness ( ) : model = MLP ( layers = [ Linear ( dim = 10 , layer_name = 'linear' , irange = 1.0 ) , Softmax ( n_classes = 2 , layer_name = 'softmax' , irange = 1.0 ) ] , batch_size = 10 , nvis = 10 ) cost = LpPenalty ( variables = model . get_params ( ) , p = 2 ) penalty = cost . expr ( model , None ) penalty_function = theano . function ( inputs = [ ] , outputs = penalty ) p = penalty_function ( ) actual_p = 0 for param in model . get_params ( ) : actual_p += numpy . sum ( ( param . get_value ( ) ** 2 ) ) assert numpy . allclose ( p , actual_p )
test the forward pass op against theano graph implementation .