|
@@ -8,7 +8,7 @@ import matplotlib.pyplot as plt
|
|
|
from sklearn.metrics import accuracy_score
|
|
from sklearn.metrics import accuracy_score
|
|
|
from sklearn.preprocessing import OneHotEncoder
|
|
from sklearn.preprocessing import OneHotEncoder
|
|
|
from tensorflow.keras import layers, losses
|
|
from tensorflow.keras import layers, losses
|
|
|
-from models.custom_layers import ExtractCentralMessage, OpticalChannel, DigitizationLayer, BitsToSymbols, SymbolsToBits
|
|
|
|
|
|
|
+from models.layers import ExtractCentralMessage, OpticalChannel, DigitizationLayer, BitsToSymbols, SymbolsToBits
|
|
|
|
|
|
|
|
|
|
|
|
|
class EndToEndAutoencoder(tf.keras.Model):
|
|
class EndToEndAutoencoder(tf.keras.Model):
|
|
@@ -248,7 +248,7 @@ class EndToEndAutoencoder(tf.keras.Model):
|
|
|
|
|
|
|
|
self.bit_error_rate = 1 - accuracy_score(bits_true, bits_pred)
|
|
self.bit_error_rate = 1 - accuracy_score(bits_true, bits_pred)
|
|
|
|
|
|
|
|
- if (length_plot):
|
|
|
|
|
|
|
+ if length_plot:
|
|
|
|
|
|
|
|
lengths = np.linspace(0, 70, 50)
|
|
lengths = np.linspace(0, 70, 50)
|
|
|
|
|
|
|
@@ -271,8 +271,9 @@ class EndToEndAutoencoder(tf.keras.Model):
|
|
|
], name="test channel (variable length)")
|
|
], name="test channel (variable length)")
|
|
|
|
|
|
|
|
X_test_l, y_test_l = self.generate_random_inputs(int(num_of_blocks))
|
|
X_test_l, y_test_l = self.generate_random_inputs(int(num_of_blocks))
|
|
|
-
|
|
|
|
|
- y_out_l = self.decoder(test_channel(self.encoder(X_test_l)))
|
|
|
|
|
|
|
+ encoded = self.encoder(X_test_l)
|
|
|
|
|
+ after_ch = test_channel(encoded)
|
|
|
|
|
+ y_out_l = self.decoder(after_ch)
|
|
|
|
|
|
|
|
y_pred_l = tf.argmax(y_out_l, axis=1)
|
|
y_pred_l = tf.argmax(y_out_l, axis=1)
|
|
|
# y_true_l = tf.argmax(y_test_l, axis=1)
|
|
# y_true_l = tf.argmax(y_test_l, axis=1)
|