#NEWLINE# @ staticmethod #NEWLINE# def gen_graph( ) : #NEWLINE# #INDENT# '\n        This method was used to generate the graph: sigmoid_prec.png in the doc.\n\n        ' #NEWLINE# data = numpy . arange ( ( - 15 ) , 15 , 0.1 ) #NEWLINE# val = ( 1 / ( 1 + numpy . exp ( ( - data ) ) ) ) #NEWLINE# def hard_sigmoid( x ) : #NEWLINE# #INDENT# return theano . tensor . nnet . hard_sigmoid ( x ) #NEWLINE# #UNINDENT# def ultra_fast_sigmoid( x ) : #NEWLINE# #INDENT# return theano . tensor . nnet . ultra_fast_sigmoid ( x ) #NEWLINE# #UNINDENT# val_hard = hard_sigmoid ( data ) . eval ( ) #NEWLINE# val_ultra = ultra_fast_sigmoid ( data ) . eval ( ) #NEWLINE# import matplotlib.pyplot as plt #NEWLINE# import os #NEWLINE# fig = plt . figure ( ) #NEWLINE# ax = fig . add_subplot ( 111 ) #NEWLINE# ax . plot ( data , val ) #NEWLINE# ax . plot ( data , val_ultra ) #NEWLINE# ax . plot ( data , val_hard ) #NEWLINE# ax . grid ( True ) #NEWLINE# ax . legend ( ( 'sigmoid' , 'ultra_fast' , 'hard' ) , 'upper left' ) #NEWLINE# fname = os . path . join ( os . path . dirname ( theano . __file__ ) , '..' , 'doc' , 'library' , 'tensor' , 'nnet' , 'sigmoid_prec.png' ) #NEWLINE# plt . savefig ( fname ) #NEWLINE# print ( 'New picture saved at' , fname ) #NEWLINE# print ( val_ultra . max ( ) ) #NEWLINE# print ( val_ultra . min ( ) )