#NEWLINE# def UpdateParameters( self , step ) : #NEWLINE# #INDENT# 'Update the encoder and decoder weigths and biases.\n    Args:\n      step: Time step of training.\n    ' #NEWLINE# numcases = self . batchsize #NEWLINE# code_layer = self . code_layer #NEWLINE# input_layer = self . input_layer #NEWLINE# encoder = self . encoder #NEWLINE# decoder = self . decoder #NEWLINE# wd = decoder . params [ 'weight' ] #NEWLINE# bd = input_layer . params [ 'bias' ] #NEWLINE# z = code_layer . state #NEWLINE# inputs = input_layer . state #NEWLINE# we = wd_delta . params [ 'weight' ] #NEWLINE# be = code_layer . params [ 'bias' ] #NEWLINE# scale = code_layer . params [ 'scale' ] #NEWLINE# code_approx = code_layer . approximator #NEWLINE# hyp = code_layer . hyperparams #NEWLINE# alpha = hyp . sc_alpha #NEWLINE# beta = hyp . sc_beta #NEWLINE# gamma = hyp . sc_gamma #NEWLINE# enc_hyp = encoder . hyperparams #NEWLINE# dec_hyp = decoder . hyperparams #NEWLINE# deriv = input_layer . deriv #NEWLINE# ( momentum , epsilon ) = decoder . GetMomentumAndEpsilon ( step ) #NEWLINE# wd_delta = self . decoder . grad_weight #NEWLINE# wd_delta . mult ( momentum ) #NEWLINE# wd_delta . add_dot ( z , deriv . T , ( beta / numcases ) ) #NEWLINE# if dec_hyp . apply_l2_decay : #NEWLINE# #INDENT# wd_delta . add_mult ( wd , alpha = dec_hyp . l2_decay ) #NEWLINE# #UNINDENT# ( momentum , epsilon ) = input_layer . GetMomentumAndEpsilon ( step ) #NEWLINE# bd_delta = input_layer . grad_bias #NEWLINE# bd_delta . mult ( momentum ) #NEWLINE# bd_delta . add_sums ( deriv , axis = 1 , mult = ( beta / numcases ) ) #NEWLINE# deriv = code_layer . deriv #NEWLINE# code_approx . div_by_col ( scale ) #NEWLINE# scale_delta = code_layer . grad_scale #NEWLINE# scale_delta . mult ( momentum ) #NEWLINE# temp = code_layer . temp3 #NEWLINE# code_approx . mult ( deriv , target = temp ) #NEWLINE# scale_delta . add_sums ( temp , axis = 1 , mult = ( alpha / numcases ) ) #NEWLINE# code_layer . deriv . mult_by_col ( scale ) #NEWLINE# code_layer . ComputeDeriv ( code_approx ) #NEWLINE# deriv = code_layer . deriv #NEWLINE# ( momentum , epsilon ) = encoder . GetMomentumAndEpsilon ( step ) #NEWLINE# we_delta = self . encoder . grad_weight #NEWLINE# we_delta . mult ( momentum ) #NEWLINE# we_delta . add_dot ( inputs , deriv . T , ( alpha / numcases ) ) #NEWLINE# if enc_hyp . apply_l2_decay : #NEWLINE# #INDENT# we_delta . add_mult ( we , alpha = enc_hyp . l2_decay ) #NEWLINE# #UNINDENT# ( momentum , epsilon ) = code_layer . GetMomentumAndEpsilon ( step ) #NEWLINE# be_delta = code_layer . grad_bias #NEWLINE# be_delta . mult ( momentum ) #NEWLINE# be_delta . add_sums ( deriv , axis = 1 , mult = ( alpha / numcases ) ) #NEWLINE# scale . add_mult ( scale_delta , ( - epsilon ) ) #NEWLINE# bd . add_mult ( bd_delta , ( - epsilon ) ) #NEWLINE# wd . add_mult ( wd_delta , ( - epsilon ) ) #NEWLINE# be . add_mult ( be_delta , ( - epsilon ) ) #NEWLINE# we . add_mult ( we_delta , ( - epsilon ) ) #NEWLINE# if dec_hyp . apply_weight_norm : #NEWLINE# #INDENT# wd . norm_limit ( dec_hyp . weight_norm , axis = 0 ) #NEWLINE# #UNINDENT# if enc_hyp . apply_weight_norm : #NEWLINE# #INDENT# we . norm_limit ( enc_hyp . weight_norm , axis = 0 )