From ee8d22b617b9f955b59a70cd212125ce1094a438 Mon Sep 17 00:00:00 2001
From: Luc Giffon <luc.giffon@lis-lab.fr>
Date: Wed, 10 Oct 2018 11:13:36 +0200
Subject: [PATCH] fix bug on init for fastfoodlayer class + add more
 tensorboard summary for nystrom approximation class

---
 .../kernel_approximation/fastfood_layer.py    |  2 +-
 .../kernel_approximation/nystrom_layer.py     |  2 ++
 skluc/main/tools/experiences/check_stderr.py  | 32 +++++++++++++++++++
 3 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 skluc/main/tools/experiences/check_stderr.py

diff --git a/skluc/main/tensorflow_/kernel_approximation/fastfood_layer.py b/skluc/main/tensorflow_/kernel_approximation/fastfood_layer.py
index d657dd7..4887080 100644
--- a/skluc/main/tensorflow_/kernel_approximation/fastfood_layer.py
+++ b/skluc/main/tensorflow_/kernel_approximation/fastfood_layer.py
@@ -159,7 +159,7 @@ def build_hadamard(n_neurons):
 
 class FastFoodLayer(tf.keras.layers.Layer):
     def __init__(self, sigma, nbr_stack, trainable=True):
-        super().__init__(self)
+        super().__init__()
         self.__sigma = sigma
         self.__nbr_stack = nbr_stack
         self.__trainable = trainable
diff --git a/skluc/main/tensorflow_/kernel_approximation/nystrom_layer.py b/skluc/main/tensorflow_/kernel_approximation/nystrom_layer.py
index 3ec4730..24c7237 100644
--- a/skluc/main/tensorflow_/kernel_approximation/nystrom_layer.py
+++ b/skluc/main/tensorflow_/kernel_approximation/nystrom_layer.py
@@ -38,6 +38,7 @@ def nystrom_layer(input_x, input_subsample, kernel, W_matrix=None, output_dim=0,
         h_conv_nystrom_subsample_flat = tf.reshape(input_subsample, [nystrom_sample_size, init_dim])
         with tf.name_scope("kernel_vec"):
             kernel_vector = kernel(h_conv_flat, h_conv_nystrom_subsample_flat, **kernel_params)
+            kernel_vector = tf.Print(kernel_vector, [kernel_vector[0]], "print op: ", summarize=10)
 
         if output_dim != 0:
             if W_matrix is None:
@@ -52,6 +53,7 @@ def nystrom_layer(input_x, input_subsample, kernel, W_matrix=None, output_dim=0,
                     raise ValueError("Unknown type for w_matrix")
             tf.summary.histogram("W_nystrom", W)
             out_fc = tf.matmul(kernel_vector, W)
+            tf.summary.histogram("Kernel vector", out_fc)
         else:
             out_fc = kernel_vector
         tf.summary.histogram("output_nystrom", out_fc)
diff --git a/skluc/main/tools/experiences/check_stderr.py b/skluc/main/tools/experiences/check_stderr.py
new file mode 100644
index 0000000..7acd919
--- /dev/null
+++ b/skluc/main/tools/experiences/check_stderr.py
@@ -0,0 +1,32 @@
+import re
+
+from os import walk
+from os.path import isfile, join
+
+if __name__ == "__main__":
+    path = "/home/luc/Resultats/Deepstrom/september_2018/deepfried_rel"
+    onlyfiles = []
+    for dirpath, dirnames, filenames in walk(path):
+        onlyfiles.extend([join(dirpath, f) for f in filenames if isfile(join(dirpath, f))])
+
+    pattern = "(.+)_stdout.txt"
+    compiled_re = re.compile(pattern)
+    errors = []
+    for f_name in onlyfiles:
+        if not compiled_re.match(f_name):
+            continue
+
+        with open(f_name, "r") as f:
+            str_f = f.read().strip()
+            if str_f == "":
+                f_name_split = f_name.split("_")
+                f_name_base = "_".join(f_name_split[:-1])
+                f_name_err = f_name_base + "_stderr.txt"
+                with open(f_name_err, 'r') as ferr:
+                    str_ferr = ferr.read().strip()
+                    errors.append(str_ferr)
+
+    with open(join(path, "errors.txt"), 'w') as f_out_err:
+        for err in errors:
+            f_out_err.write(err)
+            f_out_err.write("\n\n\n\n")
\ No newline at end of file
-- 
GitLab