-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathSISO_autoencoder22_pic.py
45 lines (36 loc) · 1.07 KB
/
SISO_autoencoder22_pic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#####################################################
#after run SISO_autoencoder22_copy.py
#####################################################
from keras.models import load_model
import numpy as np
import random as rd
import matplotlib.pyplot as plt
#initial
k = 2
n = 2
M = 2**k
R = k/n
eye_matrix = np.eye(M)
x_try = np.tile(eye_matrix, (250000, 1))
rd.shuffle(x_try)
print(x_try.shape)
ER = []
#load model
#autoencoder = load_model('autoencoder22.h5') #without n and BER
for Eb_No_dB in np.arange(-2.0, 10.0, 0.5):
belta = 1/(2*R*(10**(Eb_No_dB/10)))
belta_sqrt = np.sqrt(belta)
noise_try = belta_sqrt * np.random.randn(np.shape(x_try)[0],n)
#encoded_sys = encoder.predict(x_try)
decoded_sys_round = np.round(autoencoder.predict([x_try,noise_try]))
error_rate = np.mean(np.not_equal(x_try,decoded_sys_round).max(axis=1))
ER.append(error_rate)
print(Eb_No_dB)
print(error_rate)
#误码曲线
plt.yscale('log')
plt.plot(np.arange(-2.0, 10.0, 0.5),ER,'r.-')
plt.grid(True)
plt.ylim(10**-5, 1)
plt.xlim(-2, 10)
plt.title("Block error rate")