#NEWLINE# def get_updates( self , params , constraints , loss ) : #NEWLINE# #INDENT# grads = self . get_gradients ( loss , params ) #NEWLINE# self . updates = [ ( self . iterations , ( self . iterations + 1 ) ) ] #NEWLINE# t = ( self . iterations + 1 ) #NEWLINE# lr_t = ( ( self . lr * K . sqrt ( ( 1.0 - K . pow ( self . beta_2 , t ) ) ) ) / ( 1.0 - K . pow ( self . beta_1 , t ) ) ) #NEWLINE# ms = [ K . variable ( np . zeros ( K . get_value ( p ) . shape ) ) for p in params ] #NEWLINE# vs = [ K . variable ( np . zeros ( K . get_value ( p ) . shape ) ) for p in params ] #NEWLINE# self . weights = ( ms + vs ) #NEWLINE# for ( p , g , m , v ) in zip ( params , grads , ms , vs ) : #NEWLINE# #INDENT# m_t = ( ( self . beta_1 * m ) + ( ( 1.0 - self . beta_1 ) * g ) ) #NEWLINE# v_t = ( ( self . beta_2 * v ) + ( ( 1.0 - self . beta_2 ) * K . square ( g ) ) ) #NEWLINE# p_t = ( p - ( ( lr_t * m_t ) / ( K . sqrt ( v_t ) + self . epsilon ) ) ) #NEWLINE# self . updates . append ( ( m , m_t ) ) #NEWLINE# self . updates . append ( ( v , v_t ) ) #NEWLINE# new_p = p_t #NEWLINE# if ( p in constraints ) : #NEWLINE# #INDENT# c = constraints [ p ] #NEWLINE# new_p = c ( new_p ) #NEWLINE# #UNINDENT# self . updates . append ( ( p , new_p ) ) #NEWLINE# #UNINDENT# return self . updates