ae_MLP.train(p, training_params, validation_params) # inputs with perturbations PSR_dB = -6 num_samples = 10 ebnodb = 0 universal_per_fgm_MLP = ae_MLP.UAPattack_fgm(ebnodb, num_samples, PSR_dB) ebnodbs = np.linspace(0, 14, 15, dtype=int) batch_size = 10000 from classes.hamming import hamming_74 num_blocks = 10000 # Performace of BPSK, HD system BLER_HD, BLER_HD_adv, BLER_HD_jam = hamming_74( n, k, ebnodbs, num_blocks, universal_per_fgm_MLP.reshape(2 * n), PSR_dB) # Performace of Autoencoder BLER_No_Attack, BLER_Adv_Attack_minus6, BLER_Jamming_Attack_minus6 = ae_MLP.bler_sim_attack_AWGN( universal_per_fgm_MLP.reshape(1, 2, n), PSR_dB, ebnodbs, batch_size, 300) fig, ax = plt.subplots(dpi=1200) ax.plot(ebnodbs, BLER_Adv_Attack_minus6, 'r^-', label='White-Box Attack (Adversarial Training)') ax.plot(ebnodbs, BLER_HD_adv, 'g*--', label='White-Box Attack (BPSK, Hamming)') ax.plot(ebnodbs, BLER_HD, 's--', label='No Attack (BPSK, Hamming)') ax.plot(ebnodbs, BLER_No_Attack,
# Training ae_CNN = AE_CNN(k,n,seed) ae_CNN.train(True,0, np.zeros([1,2,n]),training_params, validation_params) # clean inputs ae_CNN.train(True,0, p,training_params, validation_params) # inputs with perturbations PSR_dB= -6 batch_size=10000 # montcarlo ebnodbs = np.linspace(0,14,15,dtype=int) from classes.hamming import hamming_74 num_blocks = 10000 # Performace of BPSK, HD system BLER_HD, BLER_HD_adv, BLER_HD_jam = hamming_74(n, k, ebnodbs, num_blocks, UAP, PSR_dB) # Performace of Autoencoder BLER_no_attack_uap_fgm6, BLER_attack_rolled_uap_fgm6, BLER_jamming1_uap_fgm6 = ae_CNN.bler_sim_attack_AWGN(False, 0, UAP.reshape(1,2,n), PSR_dB, ebnodbs, batch_size, 300) # plot fig, ax = plt.subplots(dpi=1200) ax.plot(ebnodbs, BLER_attack_rolled_uap_fgm6,'r^-',label='Black-Box Attack (Adversarial Training)') ax.plot(ebnodbs,BLER_HD_adv,'g*--',label='Black-Box Attack (BPSK)') ax.plot(ebnodbs,BLER_HD,'s--',label='No Attack (BPSK)') ax.plot(ebnodbs,BLER_no_attack_uap_fgm6,'ko-',label='No Attack (Adversarial Training)')