From 0991b53d828a49677257ac3057e65db7ee6e6e30 Mon Sep 17 00:00:00 2001 From: Joseph Bethge Date: Thu, 6 Jan 2022 17:14:15 +0100 Subject: [PATCH 1/5] image python:3.7 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a1e0edb..c6956c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: python:3.8 +image: python:3.7 before_script: - python --version From c52c72391cd96604c5555dfb393ff2f4ba189e7d Mon Sep 17 00:00:00 2001 From: Joseph Bethge Date: Thu, 6 Jan 2022 17:21:17 +0100 Subject: [PATCH 2/5] reduce version requirement --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 10fada5..fee2eac 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,7 @@ def get_requirements(file_path: Union[Path, str]): "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.7", ], - python_requires='>=3.8', + python_requires='>=3.7', ) From 68ce96c5294f8dde6ada8af46e00e5f5246778a1 Mon Sep 17 00:00:00 2001 From: Joseph Bethge Date: Fri, 21 Jan 2022 10:30:11 +0100 Subject: [PATCH 3/5] make compatible with python 3.7 --- CHANGELOG.md | 20 +++++++++++-------- .../image_classification.py | 4 ++-- .../utils/experiment_creator.py | 7 ++++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dcd9e4..bf51391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,26 +4,30 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## Unreleased +## [0.1.1] - 2022/01/21 -- [...] +### Changed + +- make package compatible with python 3.7 ## [0.1.0] - 2022/01/06 -- added basic quantized layers +### Added + +- basic quantized layers - QActivation - QConv - QLinear -- added several debug layers -- added resnet, lenet -- added various quantization functions +- several debug layers +- resnet, lenet +- various quantization functions - approxsign - dorefa - sign - steheaviside - swishsign -- added support for cifar10 and mnist -- adds general training script for image classification +- support for cifar10 and mnist +- general training script for image classification - result logger for csv and tensorboard - checkpoint manager - eta estimator diff --git a/examples/image_classification/image_classification.py b/examples/image_classification/image_classification.py index eda2721..da958dd 100644 --- a/examples/image_classification/image_classification.py +++ b/examples/image_classification/image_classification.py @@ -58,9 +58,9 @@ def main(args: argparse.Namespace, model_args: argparse.Namespace) -> None: root_directory=args.dataset_dir, download=args.download, augmentation=augmentation_level ) - train_loader = DataLoader(train_dataset, batch_size=args.batch_size, num_workers=args.num_workers, + train_loader = DataLoader(train_dataset, batch_size=args.batch_size, num_workers=args.num_workers, # type: ignore shuffle=True, pin_memory=True) # type: ignore - test_loader = DataLoader(test_dataset, batch_size=args.batch_size, num_workers=args.num_workers, + test_loader = DataLoader(test_dataset, batch_size=args.batch_size, num_workers=args.num_workers, # type: ignore shuffle=False, pin_memory=True) # type: ignore model_kwargs = vars(model_args) diff --git a/examples/image_classification/utils/experiment_creator.py b/examples/image_classification/utils/experiment_creator.py index 0759bf1..e266894 100644 --- a/examples/image_classification/utils/experiment_creator.py +++ b/examples/image_classification/utils/experiment_creator.py @@ -182,7 +182,12 @@ def create( logging.debug(f"copying {file_name}...") file_path = (self.project_root / Path(file_name)).resolve() if file_path.is_dir(): - shutil.copytree(str(file_path), str(code_path / file_name), dirs_exist_ok=True) + python_version = list(map(int, sys.version.split()[0].split("."))) + if python_version[0] == 3 and python_version[1] == 7: + # python3.7 does not have the dirs_exist_ok arg + shutil.copytree(str(file_path), str(code_path / file_name)) + else: + shutil.copytree(str(file_path), str(code_path / file_name), dirs_exist_ok=True) # type: ignore else: shutil.copy(str(file_path), str(code_path / file_name)) From 75349f30efe4d9d0c160ee1ebbcaf5676c6970a3 Mon Sep 17 00:00:00 2001 From: Joseph Bethge Date: Fri, 21 Jan 2022 10:32:59 +0100 Subject: [PATCH 4/5] adapt ci --- .gitlab-ci.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c6956c3..652f3e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: python:3.7 +image: python:3.8 before_script: - python --version @@ -8,6 +8,25 @@ before_script: - mypy --version - pytest --version +test-codestyle:3.7: + stage: test + image: python:3.7 + script: + - pwd + - ls -l + - python -c "import sys;print(sys.path)" + - flake8 --config=setup.cfg + - mypy --config-file mypy.ini + +test-units:3.7: + stage: test + image: python:3.7 + script: + - pwd + - ls -l + - python -c "import sys;print(sys.path)" + - python -m pytest . + test-codestyle: stage: test script: From 4750899e282904ae033722c8db00c112aedeabb4 Mon Sep 17 00:00:00 2001 From: Joseph Bethge Date: Fri, 21 Jan 2022 10:41:05 +0100 Subject: [PATCH 5/5] line length --- examples/image_classification/image_classification.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/image_classification/image_classification.py b/examples/image_classification/image_classification.py index da958dd..32a7ee4 100644 --- a/examples/image_classification/image_classification.py +++ b/examples/image_classification/image_classification.py @@ -58,10 +58,10 @@ def main(args: argparse.Namespace, model_args: argparse.Namespace) -> None: root_directory=args.dataset_dir, download=args.download, augmentation=augmentation_level ) - train_loader = DataLoader(train_dataset, batch_size=args.batch_size, num_workers=args.num_workers, # type: ignore - shuffle=True, pin_memory=True) # type: ignore - test_loader = DataLoader(test_dataset, batch_size=args.batch_size, num_workers=args.num_workers, # type: ignore - shuffle=False, pin_memory=True) # type: ignore + train_loader = DataLoader(train_dataset, batch_size=args.batch_size, # type: ignore + num_workers=args.num_workers, shuffle=True, pin_memory=True) # type: ignore + test_loader = DataLoader(test_dataset, batch_size=args.batch_size, # type: ignore + num_workers=args.num_workers, shuffle=False, pin_memory=True) # type: ignore model_kwargs = vars(model_args) logging.debug(f"got model args as dict: {model_kwargs}")