|
|
@@ -5,7 +5,7 @@ from sklearn.metrics import accuracy_score
|
|
|
from models import basic
|
|
|
from models.basic import AWGNChannel, BPSKDemod, BPSKMod, BypassChannel, AlphabetMod, AlphabetDemod
|
|
|
import misc
|
|
|
-from models.autoencoder import Autoencoder
|
|
|
+from models.autoencoder import Autoencoder, view_encoder
|
|
|
|
|
|
|
|
|
def show_constellation(mod, chan, demod, samples=1000):
|
|
|
@@ -62,35 +62,43 @@ if __name__ == '__main__':
|
|
|
# plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
# label='AE 4bit -25dB')
|
|
|
|
|
|
- aenc = Autoencoder(5, -25)
|
|
|
- aenc.train(samples=1e6)
|
|
|
- plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
- label='AE 5bit -25dB')
|
|
|
-
|
|
|
- aenc = Autoencoder(5, -15)
|
|
|
- aenc.train(samples=1e6)
|
|
|
- plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
- label='AE 5bit -15dB')
|
|
|
-
|
|
|
- aenc = Autoencoder(4, -25)
|
|
|
- aenc.train(samples=6e5)
|
|
|
- plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
- label='AE 4bit -20dB')
|
|
|
+ # aenc = Autoencoder(5, -25)
|
|
|
+ # aenc.train(samples=2e5)
|
|
|
+ # plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
+ # label='AE 5bit -25dB')
|
|
|
|
|
|
- aenc = Autoencoder(4, -15)
|
|
|
- aenc.train(samples=6e5)
|
|
|
- plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
- label='AE 4bit -15dB')
|
|
|
+ # view_encoder(aenc.encoder, 5)
|
|
|
+ # plt.plot(*get_AWGN_ber(AlphabetMod('32qam', 10e6), AlphabetDemod('32qam', 10e6), samples=12000, start=-15), '-',
|
|
|
+ # label='32-QAM')
|
|
|
+ # show_constellation(AlphabetMod('32qam', 10e6), AWGNChannel(-1), AlphabetDemod('32qam', 10e6))
|
|
|
+ # mod = AlphabetMod('32qam', 10e6)
|
|
|
+ # misc.display_alphabet(mod.alphabet, a_vals=True)
|
|
|
+ # pass
|
|
|
|
|
|
- aenc = Autoencoder(2, -20)
|
|
|
- aenc.train(samples=6e5)
|
|
|
- plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
- label='AE 2bit -20dB')
|
|
|
+ # aenc = Autoencoder(5, -15)
|
|
|
+ # aenc.train(samples=2e6)
|
|
|
+ # plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
+ # label='AE 5bit -15dB')
|
|
|
+ #
|
|
|
+ # aenc = Autoencoder(4, -25)
|
|
|
+ # aenc.train(samples=6e5)
|
|
|
+ # plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
+ # label='AE 4bit -20dB')
|
|
|
+ #
|
|
|
+ # aenc = Autoencoder(4, -15)
|
|
|
+ # aenc.train(samples=6e5)
|
|
|
+ # plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
+ # label='AE 4bit -15dB')
|
|
|
|
|
|
- aenc = Autoencoder(2, -15)
|
|
|
- aenc.train(samples=6e5)
|
|
|
- plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
- label='AE 2bit -15dB')
|
|
|
+ # aenc = Autoencoder(2, -20)
|
|
|
+ # aenc.train(samples=6e5)
|
|
|
+ # plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
+ # label='AE 2bit -20dB')
|
|
|
+ #
|
|
|
+ # aenc = Autoencoder(2, -15)
|
|
|
+ # aenc.train(samples=6e5)
|
|
|
+ # plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
+ # label='AE 2bit -15dB')
|
|
|
|
|
|
# aenc = Autoencoder(4, -10)
|
|
|
# aenc.train(samples=5e5)
|
|
|
@@ -102,11 +110,15 @@ if __name__ == '__main__':
|
|
|
# plt.plot(*get_AWGN_ber(aenc.get_modulator(), aenc.get_demodulator(), samples=12000, start=-15), '-',
|
|
|
# label='AE 4bit -8dB')
|
|
|
|
|
|
- plt.plot(*get_AWGN_ber(AlphabetMod('64qam', 10e6), AlphabetDemod('64qam', 10e6), samples=12000, start=-15), '-', label='64-QAM')
|
|
|
- plt.plot(*get_AWGN_ber(AlphabetMod('16qam', 10e6), AlphabetDemod('16qam', 10e6), samples=12000, start=-15), '-', label='16-QAM')
|
|
|
- plt.plot(*get_AWGN_ber(AlphabetMod('qpsk', 10e6), AlphabetDemod('qpsk', 10e6), samples=12000, start=-15), '-', label='QPSK')
|
|
|
- plt.plot(*get_AWGN_ber(AlphabetMod('8psk', 10e6), AlphabetDemod('8psk', 10e6), samples=12000, start=-15), '-', label='8PSK')
|
|
|
- plt.plot(*get_AWGN_ber(BPSKMod(10e6), BPSKDemod(10e6, 10e3), samples=12000), '-', label='BPSK')
|
|
|
+ for scheme in ['64qam', '32qam', '16qam', 'qpsk', '8psk']:
|
|
|
+ plt.plot(*get_AWGN_ber(
|
|
|
+ AlphabetMod(scheme, 10e6),
|
|
|
+ AlphabetDemod(scheme, 10e6),
|
|
|
+ samples=20e3,
|
|
|
+ steps=40,
|
|
|
+ start=-15
|
|
|
+ ), '-', label=scheme.upper())
|
|
|
+
|
|
|
plt.yscale('log')
|
|
|
plt.gca().invert_xaxis()
|
|
|
plt.grid()
|