diff --git a/README.md b/README.md index 044d7e0..277514e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This repository provides a reference implementation for learning NeuralSort-base ## Requirements -The codebase is implemented in Python 3.7. To install the necessary requirements, run the following commands: +The codebase is implemented in Python 3.6. To install the necessary requirements, run the following commands: ``` pip install -r requirements.txt diff --git a/tf/run_median.py b/tf/run_median.py index 05f4808..e98a2b0 100644 --- a/tf/run_median.py +++ b/tf/run_median.py @@ -231,7 +231,7 @@ def prnt(*args): TRAIN_PER_EPOCH = mnist_input.TRAIN_SET_SIZE // (l * M) VAL_PER_EPOCH = mnist_input.VAL_SET_SIZE // (l * M) TEST_PER_EPOCH = mnist_input.TEST_SET_SIZE // (l * M) -best_val = float('inf') +best_correct_val = float('inf') tiebreaker_val = -1 @@ -272,8 +272,8 @@ def test(epoch, val=False): if val: prnt("Validation set: correctly identified %f, mean squared error %f" % (c_i, l_v)) - if l_v < best_val: - best_val = l_v + if l_v < best_correct_val: + best_correct_val = l_v prnt('Saving...') save_model(epoch) else: diff --git a/tf/run_sort.py b/tf/run_sort.py index 0b4790c..04ad7da 100644 --- a/tf/run_sort.py +++ b/tf/run_sort.py @@ -73,7 +73,7 @@ losses = tf.reduce_mean(losses, axis=-1) loss = tf.reduce_mean(losses) -if method == 'sinkhorn': +elif method == 'sinkhorn': representations = multi_mnist_cnn.deepnn(l, X, n) pre_sinkhorn = tf.reshape(representations, [M, n, n]) P_hat = sinkhorn_operator(pre_sinkhorn, temp=temperature) @@ -84,7 +84,7 @@ losses = tf.reduce_mean(losses, axis=-1) loss = tf.reduce_mean(losses) -if method == 'gumbel_sinkhorn': +elif method == 'gumbel_sinkhorn': representations = multi_mnist_cnn.deepnn(l, X, n) pre_sinkhorn = tf.reshape(representations, [M, n, n]) P_hat = sinkhorn_operator(pre_sinkhorn, temp=temperature) @@ -102,7 +102,7 @@ losses = tf.reshape(losses, [-1]) loss = tf.reduce_mean(losses) -if method == 'deterministic_neuralsort': +elif method == 'deterministic_neuralsort': scores = multi_mnist_cnn.deepnn(l, X, 1) scores = tf.reshape(scores, [M, n, 1]) P_hat = util.neuralsort(scores, temperature) @@ -112,7 +112,7 @@ losses = tf.reduce_mean(losses, axis=-1) loss = tf.reduce_mean(losses) -if method == 'stochastic_neuralsort': +elif method == 'stochastic_neuralsort': scores = multi_mnist_cnn.deepnn(l, X, 1) scores = tf.reshape(scores, [M, n, 1]) P_hat = util.neuralsort(scores, temperature)