<s> import numpy as np <EOL> import math <EOL> import tensorflow as tf <EOL> import rmsprop_applier <EOL> class RMSPropApplierTest ( tf . test . TestCase ) : <EOL> def testApply ( self ) : <EOL> with self . test_session ( ) : <EOL> var = tf . Variable ( [ <NUM_LIT:1.0> , <NUM_LIT> ] ) <EOL> grad0 = tf . Variable ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> grad1 = tf . Variable ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> opt = rmsprop_applier . RMSPropApplier ( learning_rate = <NUM_LIT> , <EOL> decay = <NUM_LIT> , <EOL> momentum = <NUM_LIT:0.0> , <EOL> epsilon = <NUM_LIT:1.0> ) <EOL> apply_gradient0 = opt . apply_gradients ( [ var ] , [ grad0 ] ) <EOL> apply_gradient1 = opt . apply_gradients ( [ var ] , [ grad1 ] ) <EOL> tf . initialize_all_variables ( ) . run ( ) <EOL> apply_gradient0 . run ( ) <EOL> ms_x = <NUM_LIT:1.0> <EOL> ms_y = <NUM_LIT:1.0> <EOL> x = <NUM_LIT:1.0> <EOL> y = <NUM_LIT> <EOL> dx = <NUM_LIT> <EOL> dy = <NUM_LIT> <EOL> ms_x = ms_x + ( dx * dx - ms_x ) * ( <NUM_LIT:1.0> - <NUM_LIT> ) <EOL> ms_y = ms_y + ( dy * dy - ms_y ) * ( <NUM_LIT:1.0> - <NUM_LIT> ) <EOL> x = x - ( <NUM_LIT> * dx / math . sqrt ( ms_x + <NUM_LIT:1.0> ) ) <EOL> y = y - ( <NUM_LIT> * dy / math . sqrt ( ms_y + <NUM_LIT:1.0> ) ) <EOL> self . assertAllClose ( np . array ( [ x , y ] ) , var . eval ( ) ) <EOL> apply_gradient1 . run ( ) <EOL> dx = <NUM_LIT> <EOL> dy = <NUM_LIT> <EOL> ms_x = ms_x + ( dx * dx - ms_x ) * ( <NUM_LIT:1.0> - <NUM_LIT> ) <EOL> ms_y = ms_y + ( dy * dy - ms_y ) * ( <NUM_LIT:1.0> - <NUM_LIT> ) <EOL> x = x - ( <NUM_LIT> * dx / math . sqrt ( ms_x + <NUM_LIT:1.0> ) ) <EOL> y = y - ( <NUM_LIT> * dy / math . sqrt ( ms_y + <NUM_LIT:1.0> ) ) <EOL> self . assertAllClose ( np . array ( [ x , y ] ) , var . eval ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> tf . test . main ( ) </s>
