def record_attack(self, pred, landmark, attack_list, mode=0, iteration=0):
    assert (mode in [0, 1, 2, 3])
    c = pred[0].shape[0]
    diff = np.zeros([c, 2], dtype=float)
    attack_temp = list()
    defend_temp = list()
    for i in range(c):
        diff[i][0] = (abs((pred[0][i] - landmark[i][1])) * self.scale_rate_y)
        diff[i][1] = (abs((pred[1][i] - landmark[i][0])) * self.scale_rate_x)
        Radial_Error = np.sqrt((np.power(diff[(i, 0)], 2) + np.power(diff[(i, 1)], 2)))
        if (i in attack_list):
            attack_temp.append([i, (Radial_Error * self.pixel_spaceing)])
        else:
            defend_temp.append([i, (Radial_Error * self.pixel_spaceing)])
    if (iteration not in self.dict_Attack[mode].keys()):
        self.dict_Attack[mode][iteration] = list()
    self.dict_Attack[mode][iteration].append(attack_temp)
    if (iteration not in self.dict_Defend[mode].keys()):
        self.dict_Defend[mode][iteration] = list()
    self.dict_Defend[mode][iteration].append(defend_temp)
def record_attack(self, pred, landmark, attack_list, mode=0, iteration=0):
    assert (mode in [0, 1, 2, 3])
    c = pred[0].shape[0]
    diff = np.zeros([c, 2], dtype=float)
    attack_temp = list()
    defend_temp = list()
    for i in range(c):
        diff[i][0] = (abs((pred[0][i] - landmark[i][1])) * self.scale_rate_y)
        diff[i][1] = (abs((pred[1][i] - landmark[i][0])) * self.scale_rate_x)
        Radial_Error = np.sqrt((np.power(diff[(i, 0)], 2) + np.power(diff[(i, 1)], 2)))
        if (i in attack_list):
            attack_temp.append([i, (Radial_Error * self.pixel_spaceing)])
        else:
            defend_temp.append([i, (Radial_Error * self.pixel_spaceing)])
    if (iteration not in self.dict_Attack[mode].keys()):
        self.dict_Attack[mode][iteration] = list()
    self.dict_Attack[mode][iteration].append(attack_temp)
    if (iteration not in self.dict_Defend[mode].keys()):
        self.dict_Defend[mode][iteration] = list()
    self.dict_Defend[mode][iteration].append(defend_temp)