From 755cd89cf096575bb199c26de913ca405be16644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Zalewski?= Date: Mon, 22 Mar 2021 00:49:19 +0100 Subject: [PATCH] Dev (#104) * clean gitignore * update requirements.txt * add _convert_ parameter to trainer and optimizer --- .gitignore | 112 ++++-------------------------------- configs/optimizer/adam.yaml | 6 +- requirements.txt | 14 ++--- src/train.py | 2 +- 4 files changed, 21 insertions(+), 113 deletions(-) diff --git a/.gitignore b/.gitignore index 87655c1..a9cc13f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,88 +1,3 @@ -# Created by .ignore support plugin (hsz.mobi) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -.idea/ - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### VisualStudioCode template -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace -**/.vscode - -### Python template # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -213,23 +128,18 @@ dmypy.json # Pyre type checker .pyre/ -### JupyterNotebooks template -# gitignore template for Jupyter Notebooks -# website: http://jupyter.org/ +### VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace +**/.vscode -.ipynb_checkpoints -*/.ipynb_checkpoints/* +# JetBrains +.idea/ -# IPython -profile_default/ -ipython_config.py - -# Remove previous ipynb_checkpoints -# git rm -r .ipynb_checkpoints/ - - - -# Template specific +# Lightning-Hydra-Template data/ logs/ -.env.vars diff --git a/configs/optimizer/adam.yaml b/configs/optimizer/adam.yaml index 3dde771..6958926 100644 --- a/configs/optimizer/adam.yaml +++ b/configs/optimizer/adam.yaml @@ -1,8 +1,12 @@ _target_: torch.optim.Adam + # these are default parameters for Adam lr: 0.001 eps: 1e-08 weight_decay: 0 +betas: [0.9, 0.999] -# betas: [ 0.9, 0.999 ] # BUGGED :( +# _convert_ is hydra syntax needed to make betas parameter work, learn more here: +# https://hydra.cc/docs/next/advanced/instantiate_objects/overview/#parameter-conversion-strategies +_convert_: "partial" diff --git a/requirements.txt b/requirements.txt index ea297f6..f5fd8f9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,11 +2,11 @@ torch>=1.7.1 torchvision>=0.8.2 torchaudio>=0.7.2 -pytorch-lightning>=1.2.2 +pytorch-lightning>=1.2.4 torchmetrics # --------- hydra --------- # -hydra-core==1.1.0.dev3 +hydra-core==1.1.0.dev4 hydra_colorlog>=1.0.0 hydra-optuna-sweeper>=0.9.0rc2 # hydra-ray-launcher>=0.1.2 @@ -18,15 +18,9 @@ wandb>=0.10.20 # mlflow # tensorboard -# --------- linters --------- # -pre-commit -# isort -# black -# mypy - # --------- others --------- # rich>=9.12.3 python-dotenv +pre-commit dvc -# scikit-learn -# pandas +scikit-learn diff --git a/src/train.py b/src/train.py index dc69b0d..721e30c 100644 --- a/src/train.py +++ b/src/train.py @@ -59,7 +59,7 @@ def train(config: DictConfig) -> Optional[float]: # Init Lightning trainer log.info(f"Instantiating trainer <{config.trainer._target_}>") trainer: Trainer = hydra.utils.instantiate( - config.trainer, callbacks=callbacks, logger=logger + config.trainer, callbacks=callbacks, logger=logger, _convert_="partial" ) # Send some parameters from config to all lightning loggers