def test_constant_get_stabilized():
 x2 = T.scalar()
 y2 = T.log((1 + T.exp(x2)))
 mode = theano.compile.get_default_mode()
 mode.check_isfinite = False
 f2 = theano.function([x2], y2, mode=mode)
 try:
  assert (len(f2.maker.fgraph.toposort()) == 1)
  assert (f2.maker.fgraph.toposort()[0].op == theano.tensor.nnet.sigm.softplus)
  assert (f2(800) == 800)
  x = T.as_tensor_variable(800)
  y = T.log((1 + T.exp(x)))
  f = theano.function([], y, mode=mode)
  assert (len(f.maker.fgraph.toposort()) == 0)
  assert numpy.isinf(f())
  assert (f() == 800), f()
 except AssertionError:
  raise SkipTest('Theano optimizes constant before stabilization. This breaks stabilization optimization in some cases. See #504.')

def test_constant_get_stabilized ( ) : x2 = T . scalar ( ) y2 = T . log ( ( 1 + T . exp ( x2 ) ) ) mode = theano . compile . get_default_mode ( ) mode . check_isfinite = False f2 = theano . function ( [ x2 ] , y2 , mode = mode ) try : assert ( len ( f2 . maker . fgraph . toposort ( ) ) == 1 ) assert ( f2 . maker . fgraph . toposort ( ) [ 0 ] . op == theano . tensor . nnet . sigm . softplus ) assert ( f2 ( 800 ) == 800 ) x = T . as_tensor_variable ( 800 ) y = T . log ( ( 1 + T . exp ( x ) ) ) f = theano . function ( [ ] , y , mode = mode ) assert ( len ( f . maker . fgraph . toposort ( ) ) == 0 ) assert numpy . isinf ( f ( ) ) assert ( f ( ) == 800 ) , f ( ) except AssertionError : raise SkipTest ( 'Theano optimizes constant before stabilization. This breaks stabilization optimization in some cases. See #504.' )
currently theano enable the constant_folding optimization before stabilization optimization .