def test_optimizer():
 nan_detected = [False]
 def detect_nan(i, node, fn):
  for output in fn.outputs:
   if numpy.isnan(output[0]).any():
    print('*** NaN detected ***')
    theano.printing.debugprint(node)
    print(('Inputs : %s' % [input[0] for input in fn.inputs]))
    print(('Outputs: %s' % [output[0] for output in fn.outputs]))
    nan_detected[0] = True
    break
 x = theano.tensor.dscalar('x')
 mode = theano.compile.MonitorMode(post_func=detect_nan)
 mode = mode.excluding('fusion')
 f = theano.function([x], [(theano.tensor.log(x) * x)], mode=mode)
 assert (len(f.maker.fgraph.apply_nodes) == 2)
 f(0)
 assert nan_detected[0]

def test_optimizer ( ) : nan_detected = [ False ] def detect_nan ( i , node , fn ) : for output in fn . outputs : if numpy . isnan ( output [ 0 ] ) . any ( ) : print ( '*** NaN detected ***' ) theano . printing . debugprint ( node ) print ( ( 'Inputs : %s' % [ input [ 0 ] for input in fn . inputs ] ) ) print ( ( 'Outputs: %s' % [ output [ 0 ] for output in fn . outputs ] ) ) nan_detected [ 0 ] = True break x = theano . tensor . dscalar ( 'x' ) mode = theano . compile . MonitorMode ( post_func = detect_nan ) mode = mode . excluding ( 'fusion' ) f = theano . function ( [ x ] , [ ( theano . tensor . log ( x ) * x ) ] , mode = mode ) assert ( len ( f . maker . fgraph . apply_nodes ) == 2 ) f ( 0 ) assert nan_detected [ 0 ]
test that we can remove optimizer .