self.gb1_sum_squere += self.gb1 ** 2 self.gW1_sum_squere += self.gW1 ** 2 def param_update(self): ''' パラメータの更新 ''' self.W2 -= self.eta / (np.sqrt(self.gW2_sum_squere + 1)) * self.gW2_sum / self.batch_size self.b2 -= self.eta / (np.sqrt(self.gb2_sum_squere + 1)) * self.gb2_sum / self.batch_size self.W1 -= self.eta / (np.sqrt(self.gW1_sum_squere + 1)) * self.gW1_sum / self.batch_size self.b1 -= self.eta / (np.sqrt(self.gb1_sum_squere + 1)) * self.gb1_sum / self.batch_size def init_grad_sum(self): self.gb2_sum = np.zeros(self.data['D']) self.gW2_sum = np.zeros((self.data['D'], self.hidden_dim_num)) self.gb1_sum = np.zeros(self.hidden_dim_num) self.gW1_sum = np.zeros((self.hidden_dim_num, self.data['D'])) self.gb2_sum_squere = np.zeros(self.data['D']) self.gW2_sum_squere = np.zeros((self.data['D'], self.hidden_dim_num)) self.gb1_sum_squere = np.zeros(self.hidden_dim_num) self.gW1_sum_squere = np.zeros((self.hidden_dim_num, self.data['D'])) def sigmoid(x): return 1.0 / (1.0 + np.exp(-x)) if __name__ == '__main__': ae = AutoEncoderAll('./data/dataset.dat') ae.calc_loss_and_params() data.print_params2file(ae.get_best_params(), './results/result_test.txt')
パラメータの更新 ''' self.W2 -= self.eta / (np.sqrt(self.gW2_sum_squere + 1)) * self.gW2_sum / self.batch_size self.b2 -= self.eta / (np.sqrt(self.gb2_sum_squere + 1)) * self.gb2_sum / self.batch_size self.W1 -= self.eta / (np.sqrt(self.gW1_sum_squere + 1)) * self.gW1_sum / self.batch_size self.b1 -= self.eta / (np.sqrt(self.gb1_sum_squere + 1)) * self.gb1_sum / self.batch_size def init_grad_sum(self): self.gb2_sum = np.zeros(self.data['D']) self.gW2_sum = np.zeros((self.data['D'], self.hidden_dim_num)) self.gb1_sum = np.zeros(self.hidden_dim_num) self.gW1_sum = np.zeros((self.hidden_dim_num, self.data['D'])) self.gb2_sum_squere = np.zeros(self.data['D']) self.gW2_sum_squere = np.zeros((self.data['D'], self.hidden_dim_num)) self.gb1_sum_squere = np.zeros(self.hidden_dim_num) self.gW1_sum_squere = np.zeros((self.hidden_dim_num, self.data['D'])) def sigmoid(x): return 1.0 / (1.0 + np.exp(-x)) if __name__ == '__main__': ae = AutoEncoderAll('./data/dataset.dat') ae.calc_loss_and_params() data.print_params2file(ae.get_best_params(), './results/result_test.txt')