kiudee / cs-ranking

Context-sensitive ranking and choice in Python with PyTorch
https://cs-ranking.readthedocs.io
Apache License 2.0
66 stars 15 forks source link

Migrate to PyTorch #191

Closed kiudee closed 3 years ago

kiudee commented 3 years ago

Description

Replaces Tensorflow v1.x with PyTorch 1.8. The most important neural network learners have been converted:

In order to fully support scikit-learn interoperability, we also include skorch now as dependency.

The old master branch corresponding to v1.x.y will be continued here to facilitate bug fixes: https://github.com/kiudee/cs-ranking/tree/v1.x

Motivation and Context

The code base depends heavily on Tensorflow v1, which is no longer updated due to the major update to Tensorflow v2. Since a major rewrite to support Tensorflow v2 would have been necessary, we deliberated whether it is better to switch over to PyTorch instead. Finally, we decided to go for PyTorch, since we also switched to it on other projects and the momentum of the research community is currently behind it.

Special thanks go to @timokau who worked hard on making this migration a reality.

How Has This Been Tested?

The tests of the learners have been adapted to use PyTorch. The tests were run locally and on GitHub Actions to confirm that everything passes.

Does this close/impact existing issues?

Resolves #125, resolves #153, resolves #146, fixes #130, closes #105, closes #43.

Types of changes

Checklist:

codecov[bot] commented 3 years ago

Codecov Report

Merging #191 (7c1f922) into master (1217c46) will decrease coverage by 4.90%. The diff coverage is 87.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
- Coverage   57.04%   52.14%   -4.91%     
==========================================
  Files         113      102      -11     
  Lines        6560     5090    -1470     
==========================================
- Hits         3742     2654    -1088     
+ Misses       2818     2436     -382     
Impacted Files Coverage Δ
csrank/choicefunction/__init__.py 100.00% <ø> (ø)
csrank/choicefunction/baseline.py 37.93% <0.00%> (-1.36%) :arrow_down:
csrank/constants.py 100.00% <ø> (ø)
csrank/core/__init__.py 100.00% <ø> (ø)
csrank/dataset_reader/dataset_reader.py 68.57% <ø> (+27.39%) :arrow_up:
csrank/dataset_reader/discretechoice/util.py 22.41% <ø> (+6.89%) :arrow_up:
...nk/dataset_reader/letor_listwise_dataset_reader.py 14.56% <ø> (ø)
...ank/dataset_reader/letor_ranking_dataset_reader.py 14.52% <ø> (ø)
csrank/dataset_reader/util.py 36.44% <ø> (+18.64%) :arrow_up:
csrank/discretechoice/__init__.py 100.00% <ø> (ø)
... and 87 more