def test_kl():
 init_mode = theano.config.compute_test_value
 theano.config.compute_test_value = 'raise'
 try:
  mlp = MLP(layers=[Sigmoid(dim=10, layer_name='Y', irange=0.1)], nvis=10)
  X = mlp.get_input_space().make_theano_batch()
  Y = mlp.get_output_space().make_theano_batch()
  X.tag.test_value = np.random.random(get_debug_values(X)[0].shape).astype(theano.config.floatX)
  Y_hat = mlp.fprop(X)
  ave = kl(Y, Y_hat, 1)
  Y.tag.test_value[2][3] = 1.1
  np.testing.assert_raises(ValueError, kl, Y, Y_hat, 1)
  Y.tag.test_value[2][3] = (-0.1)
  np.testing.assert_raises(ValueError, kl, Y, Y_hat, 1)
 finally:
  theano.config.compute_test_value = init_mode

def test_kl ( ) : init_mode = theano . config . compute_test_value theano . config . compute_test_value = 'raise' try : mlp = MLP ( layers = [ Sigmoid ( dim = 10 , layer_name = 'Y' , irange = 0.1 ) ] , nvis = 10 ) X = mlp . get_input_space ( ) . make_theano_batch ( ) Y = mlp . get_output_space ( ) . make_theano_batch ( ) X . tag . test_value = np . random . random ( get_debug_values ( X ) [ 0 ] . shape ) . astype ( theano . config . floatX ) Y_hat = mlp . fprop ( X ) ave = kl ( Y , Y_hat , 1 ) Y . tag . test_value [ 2 ] [ 3 ] = 1.1 np . testing . assert_raises ( ValueError , kl , Y , Y_hat , 1 ) Y . tag . test_value [ 2 ] [ 3 ] = ( - 0.1 ) np . testing . assert_raises ( ValueError , kl , Y , Y_hat , 1 ) finally : theano . config . compute_test_value = init_mode
test whether function kl() has properly processed the input .