Avoid nan loss when there are labels with no samples in the training data. #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continious Integration | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
operating-system: [ubuntu-latest, windows-latest, macos-latest] | |
python-version: [3.7, 3.8, 3.9] | |
torch-version: [1.10.2, 1.11.0, 1.12.0] | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Restore Ubuntu cache | |
uses: actions/cache@v1 | |
if: matrix.operating-system == 'ubuntu-latest' | |
with: | |
path: ~/.cache/pip | |
key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}} | |
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}- | |
- name: Restore MacOS cache | |
uses: actions/cache@v1 | |
if: matrix.operating-system == 'macos-latest' | |
with: | |
path: ~/Library/Caches/pip | |
key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}} | |
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}- | |
- name: Restore Windows cache | |
uses: actions/cache@v1 | |
if: matrix.operating-system == 'windows-latest' | |
with: | |
path: ~\AppData\Local\pip\Cache | |
key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}} | |
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}- | |
- name: Update pip | |
run: python -m pip install --upgrade pip | |
- name: Lint with flake8, black and isort | |
run: | | |
pip install -e .[dev] | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
black . --check --config pyproject.toml | |
isort -c . | |
# exit-zero treats all errors as warnings. Allowed max line length is 120. | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics | |
- name: Install Numpy | |
run: > | |
pip install numpy | |
- name: Install PyTorch on Linux and Windows | |
if: > | |
matrix.operating-system == 'ubuntu-latest' || | |
matrix.operating-system == 'windows-latest' | |
run: > | |
pip install torch==${{ matrix.torch-version }}+cpu | |
-f https://download.pytorch.org/whl/torch_stable.html | |
- name: Install PyTorch on MacOS | |
if: matrix.operating-system == 'macos-latest' | |
run: pip install torch==${{ matrix.torch-version }} | |
- name: Install balanced-loss package from local setup.py | |
run: > | |
pip install -e . | |
- name: Unittest balanced-loss | |
run: | | |
python -m unittest |