#NEWLINE# def optimize( self , inputs , extra_inputs = None ) : #NEWLINE# #INDENT# if ( extra_inputs is None ) : #NEWLINE# #INDENT# extra_inputs = list ( ) #NEWLINE# #UNINDENT# dataset = BatchDataset ( inputs = inputs , batch_size = self . _batch_size , extra_inputs = extra_inputs ) #NEWLINE# cg_dataset = BatchDataset ( inputs = inputs , batch_size = self . _cg_batch_size , extra_inputs = extra_inputs ) #NEWLINE# itr = [ 0 ] #NEWLINE# start_time = time . time ( ) #NEWLINE# if self . _callback : #NEWLINE# #INDENT# def opt_callback( ) : #NEWLINE# #INDENT# loss = self . _opt_fun [ 'f_loss' ] ( * ( inputs + extra_inputs ) ) #NEWLINE# elapsed = ( time . time ( ) - start_time ) #NEWLINE# self . _callback ( dict ( loss = loss , params = self . _target . get_param_values ( trainable = True ) , itr = itr [ 0 ] , elapsed = elapsed ) ) #NEWLINE# itr [ 0 ] += 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# opt_callback = None #NEWLINE# #UNINDENT# self . _hf_optimizer . train ( gradient_dataset = dataset , cg_dataset = cg_dataset , itr_callback = opt_callback , num_updates = self . _max_opt_itr , preconditioner = True , verbose = True )