Skip to content

Commit

Permalink
Merge ed66aa9 into 07a6faf
Browse files Browse the repository at this point in the history
  • Loading branch information
timokau committed Nov 14, 2019
2 parents 07a6faf + ed66aa9 commit 7419239
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions csrank/tests/test_choice_functions.py
Expand Up @@ -10,7 +10,7 @@
from csrank.experiments.constants import *
from csrank.experiments.util import metrics_on_predictions
from csrank.metrics_np import f1_measure, subset_01_loss, instance_informedness, auc_score
from csrank.tests.test_ranking import check_leaner
from csrank.tests.test_ranking import check_learner

choice_metrics = {'F1Score': f1_measure, 'Informedness': instance_informedness, "AucScore": auc_score}
optimizer = SGD(lr=1e-3, momentum=0.9, nesterov=True)
Expand Down Expand Up @@ -77,4 +77,4 @@ def test_choice_function_fixed(trivial_choice_problem, name):
"batch_size": 32, "alpha": 0.5, "l1_ratio": 0.7, "tol": 1e-2, "C": 10, "n_mixtures": 10, "n_nests": 5,
"regularization": "l2"}
learner.set_tunable_parameters(**params)
check_leaner(learner, params, rtol, atol)
check_learner(learner, params, rtol, atol)
4 changes: 2 additions & 2 deletions csrank/tests/test_discrete_choice.py
Expand Up @@ -11,7 +11,7 @@
from csrank.experiments.constants import *
from csrank.experiments.util import metrics_on_predictions
from csrank.metrics_np import categorical_accuracy_np, topk_categorical_accuracy_np, subset_01_loss
from csrank.tests.test_ranking import check_leaner
from csrank.tests.test_ranking import check_learner

metrics = {'CategoricalAccuracy': categorical_accuracy_np, 'CategoricalTopK2': topk_categorical_accuracy_np(k=2)}
optimizer = SGD(lr=1e-3, momentum=0.9, nesterov=True)
Expand Down Expand Up @@ -85,4 +85,4 @@ def test_discrete_choice_function_fixed(trivial_discrete_choice_problem, name):
"batch_size": 32, "alpha": 0.5, "l1_ratio": 0.7, "tol": 1e-2, "C": 10, "n_mixtures": 10, "n_nests": 5,
"regularization": "l2"}
learner.set_tunable_parameters(**params)
check_leaner(learner, params, rtol, atol)
check_learner(learner, params, rtol, atol)
2 changes: 1 addition & 1 deletion csrank/tests/test_fate.py
Expand Up @@ -53,7 +53,7 @@ def fit(self, *args, **kwargs):
assert grc.batch_size == params["batch_size"]
rtol = 1e-2
atol = 1e-4
assert np.isclose(grc.optimizer.get_config()['lr'], params["learning_rate"], rtol=rtol, atol=atol, equal_nan=False)
assert np.isclose(grc.optimizer.get_config()['learning_rate'], params["learning_rate"], rtol=rtol, atol=atol, equal_nan=False)
config = grc.kernel_regularizer.get_config()
val1 = np.isclose(config["l1"], params["reg_strength"], rtol=rtol, atol=atol, equal_nan=False)
val2 = np.isclose(config["l2"], params["reg_strength"], rtol=rtol, atol=atol, equal_nan=False)
Expand Down
6 changes: 3 additions & 3 deletions csrank/tests/test_ranking.py
Expand Up @@ -35,7 +35,7 @@ def trivial_ranking_problem():
return x, y_true


def check_leaner(ranker, params, rtol=1e-2, atol=1e-4):
def check_learner(ranker, params, rtol=1e-2, atol=1e-4):
for key, value in params.items():
if key in ranker.__dict__.keys():
expected = ranker.__dict__[key]
Expand All @@ -47,7 +47,7 @@ def check_leaner(ranker, params, rtol=1e-2, atol=1e-4):
else:
assert value == expected
elif key == "learning_rate" and "optimizer" in ranker.__dict__.keys():
assert np.isclose(ranker.optimizer.get_config()['lr'], value, rtol=rtol, atol=atol, equal_nan=False)
assert np.isclose(ranker.optimizer.get_config()['learning_rate'], value, rtol=rtol, atol=atol, equal_nan=False)
elif key == "reg_strength" and "kernel_regularizer" in ranker.__dict__.keys():
config = ranker.kernel_regularizer.get_config()
val1 = np.isclose(config["l1"], value, rtol=rtol, atol=atol, equal_nan=False)
Expand Down Expand Up @@ -86,4 +86,4 @@ def test_object_ranker_fixed(trivial_ranking_problem, ranker_name):
"batch_size": 32, "alpha": 0.5, "l1_ratio": 0.7, "tol": 1e-2, "C": 10, "n_mixtures": 10, "n_nests": 5,
"regularization": "l2"}
ranker.set_tunable_parameters(**params)
check_leaner(ranker, params, rtol, atol)
check_learner(ranker, params, rtol, atol)
3 changes: 1 addition & 2 deletions requirements.txt
Expand Up @@ -9,8 +9,7 @@ psycopg2-binary>=2.7
docopt>=0.6.0
joblib>=0.9.4
tqdm>=4.11.2
# keras 2.3 renamed `lr` to `learning_rate`, we will deal with that in the tf2 transition
keras>=2.1.5,<2.3
keras>=2.3
pymc3>=3.5
theano>=1.0
# Pick either CPU or GPU version of tensorflow:
Expand Down

0 comments on commit 7419239

Please sign in to comment.