From 04541053dd1fbacbd4323f97d62964d83256fb6d Mon Sep 17 00:00:00 2001
From: lucas_miranda <lucasmiranda42@gmail.com>
Date: Thu, 17 Sep 2020 20:43:47 +0200
Subject: [PATCH] Reformatted files

---
 deepof/hypermodels.py | 4 ++--
 deepof/model_utils.py | 9 ++++++++-
 deepof/models.py      | 2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/deepof/hypermodels.py b/deepof/hypermodels.py
index 5904092e..4962642f 100644
--- a/deepof/hypermodels.py
+++ b/deepof/hypermodels.py
@@ -92,7 +92,7 @@ class SEQ_2_SEQ_AE(HyperModel):
             ENCODING,
             activation="relu",
             kernel_constraint=UnitNorm(axis=1),
-            activity_regularizer=UncorrelatedFeaturesConstraint(3, weightage=1.0),
+            activity_regularizer=uncorrelated_features_constraint(3, weightage=1.0),
             kernel_initializer=Orthogonal(),
         )
 
@@ -340,7 +340,7 @@ class SEQ_2_SEQ_GMVAE(HyperModel):
                     for k in range(self.number_of_components)
                 ],
             ),
-            activity_regularizer=UncorrelatedFeaturesConstraint(3, weightage=1.0),
+            activity_regularizer=uncorrelated_features_constraint(3, weightage=1.0),
         )([z_cat, z_gauss])
 
         if "ELBO" in self.loss:
diff --git a/deepof/model_utils.py b/deepof/model_utils.py
index a2778d75..60a26318 100644
--- a/deepof/model_utils.py
+++ b/deepof/model_utils.py
@@ -172,7 +172,14 @@ class one_cycle_scheduler(tf.keras.callbacks.Callback):
         K.set_value(self.model.optimizer.lr, rate)
 
 
-class UncorrelatedFeaturesConstraint(Constraint):
+class uncorrelated_features_constraint(Constraint):
+    """
+
+    Tensorflow Constraint subclass that forces a layer to have uncorrelated features.
+    Useful, among others, for auto encoder bottleneck layers
+
+    """
+
     def __init__(self, encoding_dim, weightage=1.0):
         self.encoding_dim = encoding_dim
         self.weightage = weightage
diff --git a/deepof/models.py b/deepof/models.py
index e07069e1..6ac1cc6e 100644
--- a/deepof/models.py
+++ b/deepof/models.py
@@ -92,7 +92,7 @@ class SEQ_2_SEQ_AE:
             self.ENCODING,
             activation="elu",
             kernel_constraint=UnitNorm(axis=1),
-            activity_regularizer=UncorrelatedFeaturesConstraint(2, weightage=1.0),
+            activity_regularizer=uncorrelated_features_constraint(2, weightage=1.0),
             kernel_initializer=Orthogonal(),
         )
 
-- 
GitLab