{"id":24293547,"url":"https://github.com/adrianmarino/pytorch-common","last_synced_at":"2026-04-15T20:33:03.301Z","repository":{"id":57457903,"uuid":"446179686","full_name":"adrianmarino/pytorch-common","owner":"adrianmarino","description":"A library of pytorch helper classes and modules that speeds up models building.","archived":false,"fork":false,"pushed_at":"2023-09-02T22:45:54.000Z","size":152,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-21T02:57:51.117Z","etag":null,"topics":["deep-learning","python","pytorch"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pytorch-common","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adrianmarino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-01-09T19:11:10.000Z","updated_at":"2022-02-17T02:46:30.000Z","dependencies_parsed_at":"2022-09-07T01:53:37.124Z","dependency_job_id":null,"html_url":"https://github.com/adrianmarino/pytorch-common","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/adrianmarino/pytorch-common","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmarino%2Fpytorch-common","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmarino%2Fpytorch-common/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmarino%2Fpytorch-common/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmarino%2Fpytorch-common/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adrianmarino","download_url":"https://codeload.github.com/adrianmarino/pytorch-common/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmarino%2Fpytorch-common/sbom","scorecard":{"id":167894,"data":{"date":"2025-08-11","repo":{"name":"github.com/adrianmarino/pytorch-common","commit":"cfded12b740df99eccb9e4630f503d556181b7ea"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":0,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":0,"reason":"binaries present in source code","details":["Warn: binary detected: pytorch_common/__pycache__/__init__.cpython-310.pyc:1","Warn: binary detected: pytorch_common/__pycache__/__init__.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/__init__.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/__init__.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/callback.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/callback.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/callback_manager.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/early_stop.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/reduce_lr_on_plateau.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/reduce_lr_on_plateau.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/save_best_model_checkpoint.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/validation.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/__pycache__/validation.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/mixin/__pycache__/metric_improve_mixin.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/__pycache__/__init__.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/__pycache__/__init__.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/__pycache__/logger_callback.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/__pycache__/logger_callback.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/__pycache__/output_callback.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/__pycache__/output_callback.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/__pycache__/output_hook_callback.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/plot/__pycache__/__init__.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/plot/__pycache__/__init__.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/plot/__pycache__/metric_logger.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/plot/__pycache__/metric_logger.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/plot/__pycache__/metrics_plotter.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/plot/__pycache__/metrics_plotter.cpython-39.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/plot/__pycache__/plot.cpython-310.pyc:1","Warn: binary detected: pytorch_common/callbacks/output/plot/__pycache__/plot.cpython-39.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/__init__.cpython-310.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/__init__.cpython-39.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/common_mixin.cpython-310.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/common_mixin.cpython-39.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/fit_context.cpython-310.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/fit_mixin.cpython-310.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/fit_mixin.cpython-39.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/fn.cpython-310.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/persistent_mixin.cpython-310.pyc:1","Warn: binary detected: pytorch_common/modules/__pycache__/predict_mixin.cpython-310.pyc:1","Warn: binary detected: pytorch_common/util/__pycache__/__init__.cpython-310.pyc:1","Warn: binary detected: pytorch_common/util/__pycache__/data_utils.cpython-310.pyc:1","Warn: binary detected: pytorch_common/util/__pycache__/device_utils.cpython-310.pyc:1","Warn: binary detected: pytorch_common/util/__pycache__/logger.cpython-310.pyc:1","Warn: binary detected: pytorch_common/util/__pycache__/module_utils.cpython-310.pyc:1","Warn: binary detected: pytorch_common/util/__pycache__/os_utils.cpython-310.pyc:1","Warn: binary detected: pytorch_common/util/__pycache__/stopwatch.cpython-310.pyc:1","Warn: binary detected: pytorch_common/util/__pycache__/tensor_utils.cpython-310.pyc:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"27 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-6673-4983-2vx5","Warn: Project is vulnerable to: GHSA-29gw-9793-fvw7","Warn: Project is vulnerable to: PYSEC-2022-288 / GHSA-6hrg-qmvc-2xh8","Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: GHSA-3f63-hfp8-52jq","Warn: Project is vulnerable to: GHSA-44wm-f244-xhp3","Warn: Project is vulnerable to: PYSEC-2023-227 / GHSA-8ghj-p4vj-mr35","Warn: Project is vulnerable to: PYSEC-2022-43145 / GHSA-hr8g-f6r6-mr22","Warn: Project is vulnerable to: GHSA-j7hp-h8jx-5ppr","Warn: Project is vulnerable to: PYSEC-2022-42979 / GHSA-m2vv-5vj5-2hm7","Warn: Project is vulnerable to: OSV-2022-1074","Warn: Project is vulnerable to: OSV-2022-715","Warn: Project is vulnerable to: PYSEC-2023-175","Warn: Project is vulnerable to: PYSEC-2022-42969","Warn: Project is vulnerable to: PYSEC-2023-117 / GHSA-mrwq-x4v8-fh7p","Warn: Project is vulnerable to: PYSEC-2024-110 / GHSA-jw8x-6495-233v","Warn: Project is vulnerable to: PYSEC-2023-102","Warn: Project is vulnerable to: PYSEC-2023-114","Warn: Project is vulnerable to: GHSA-3749-ghw9-m3mg","Warn: Project is vulnerable to: PYSEC-2022-43015 / GHSA-47fc-vmwq-366v","Warn: Project is vulnerable to: PYSEC-2025-41 / GHSA-53q9-r3pm-6pq6","Warn: Project is vulnerable to: PYSEC-2024-252 / GHSA-5pcm-hx3q-hm94","Warn: Project is vulnerable to: GHSA-887c-mr87-cxwp","Warn: Project is vulnerable to: PYSEC-2024-251 / GHSA-pg7h-5qx3-wjr3","Warn: Project is vulnerable to: PYSEC-2024-250","Warn: Project is vulnerable to: PYSEC-2024-259","Warn: Project is vulnerable to: GHSA-jfmj-5v4g-7637"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T15:26:26.367Z","repository_id":57457903,"created_at":"2025-08-16T15:26:26.367Z","updated_at":"2025-08-16T15:26:26.367Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31859447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","python","pytorch"],"created_at":"2025-01-16T16:29:52.370Z","updated_at":"2026-04-15T20:33:03.283Z","avatar_url":"https://github.com/adrianmarino.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytorch-common\n\nA [Pypi module](https://pypi.org/project/pytorch-common/) with pytorch common tools like:\n\n\n## Build release\n\n**Step 1**: Increase version into next files:\n\n```bash\npytorch_common/__init__.py\npyproject.toml\n```\n\n**Step 2**: Build release.\n\n```bash\n$ poetry build                                                                                                                                                                                                                  ✔  \n\nBuilding pytorch-common (0.2.3)\n  - Building sdist\n  - Built pytorch-common-0.2.3.tar.gz\n  - Building wheel\n  - Built pytorch_common-0.2.3-py3-none-any.whl\n```\n\n**Step 3**: Publish release to PyPI repository.\n\n```bash\n$ poetry publish                                                                                                                                                                                                                  ✔  \n\nPublishing pytorch-common (0.2.3) to PyPI\n - Uploading pytorch-common-0.2.3.tar.gz 100%\n - Uploading pytorch_common-0.2.3-py3-none-any.whl 100%\n```\n\n\n## Features\n\n* **Callbacks** (keras style)\n  * **Validation**: Model validation.\n  * **ReduceLROnPlateau**:\n    * Reduce learning rate when a metric has stopped improving.\n    * Models often benefit from reducing the learning rate by a factor\n      of 2-10 once learning stagnates. This scheduler reads a metrics\n      quantity and if no improvement is seen for a 'patience' number\n      of epochs, the learning rate is reduced.\n  * **EarlyStop**:\n    * Stop training when model has stopped improving a specified metric.\n  * **SaveBestModel**:\n    * Save model weights to file while model validation metric improve.\n  * **Logger**:\n    * Logs context properties.\n    * In general is used to log performance metrics every n epochs.\n  * **MetricsPlotter**:\n    * Plot evaluation metrics.\n    * This graph is updated every n epochs during training process.\n    * Allow save each plot into a file.\n  * **Callback** and **OutputCallback**:\n    * Base classes.\n  * **CallbackManager**:\n    * Simplify callbacks support to fit custom models.\n* **StratifiedKFoldCV**:\n  * Support parallel fold processing on CPU.\n* **Mixins**\n  * `FiMixin`\n    * `fit(data_loader, loss_fn, epochs, optimizer, callbacks, verbose, extra_ctx, train_fn)` \n  * `CommonMixin`\n    * `params()`: Get model params.\n    * Get associated `device`.\n  * `PredictMixin`\n    * `evaluate(data_loader)`\n    * `evaluate_score(data_loader, score_fn)`\n    * `predict(features)`\n  * `PersistentMixin`\n    * `save(path)`\n    * `load(path)`\n* **Utils**\n  * device management\n  * `Stopwatch`\n  * data split\n  * os\n  * model\n  * `LoggerBuilder`\n  * Dict Utils\n  * `WeightsFileResolver`: Resolver best model weights file path using a given metric like `min` `eva_loss`, `max` `eval_acc`, etc...\n* **Plot**\n  *  Plot primitives like `plot_loss`.\n\n## Examples\n\n### Device management\n\n\n```python\nimport pytorch_common.util as pu\n\n# Setup prefered device.\npu.set_device_name('gpu') # / 'cpu'\n\n# Setup GPU memory fraction for a process (%).\npu.set_device_memory(\n  'gpu' # / 'cpu',\n  process_memory_fraction=0.5\n)\n\n# Get prefered device.\n# Note: In case the preferred device is not found, it returns CPU as fallback.\ndevice = pu.get_device()\n```\n\n### Logging\n\n\n```python\nimport logging\nimport pytorch_common.util as pu\n\n## Default loggin in console...\npu.LoggerBuilder() \\\n .on_console() \\\n .build()\n\n## Setup format and level...\npu.LoggerBuilder() \\\n .level(logging.ERROR) \\\n .on_console('%(asctime)s - %(levelname)s - %(message)s') \\\n .build()\n```\n\n\n### Stopwatch\n\n\n```python\nimport logging\nimport pytorch_common.util as pu\n\nsw = pu.Stopwatch()\n\n# Call any demanding process...\n\n# Get resposne time.\nresposne_time = sw.elapsed_time()\n\n# Log resposne time.\nlogging.info(sw.to_str())\n```\n\n\n### Dataset split\n\n\n```python\nimport pytorch_common.util as pu\n\ndataset = ... # \u003c-- Torch.utils.data.Dataset\n\ntrain_subset, test_subset = pu.train_val_split(\n  dataset,\n  train_percent = .7\n)\n\ntrain_subset, val_subset, test_subset = pu.train_val_test_split(\n  dataset,\n  train_percent = .7,\n  val_percent   = .15\n)\n```\n\n\n### Kfolding\n\n```python\nimport logging\nfrom pytorch_common.kfoldcv import StratifiedKFoldCV, \\\n                                   ParallelKFoldCVStrategy, \\\n                                   NonParallelKFoldCVStrategy\n\n# Call your model under this function..\ndef train_fold_fn(dataset, train_idx, val_idx, params, fold):\n  pass\n\n# Get dataset labels\ndef get_y_values_fn(dataset):\n  pass\n\ncv = StratifiedKFoldCV(\n  train_fold_fn,\n  get_y_values_fn,\n  strategy=NonParallelKFoldCVStrategy() # or ParallelKFoldCVStrategy()\n  k_fold = 5\n)\n\n# Model hyperparams...\nparams = {\n    'seed': 42,\n    'lr': 0.01,\n    'epochs': 50,\n    'batch_size': 4000,\n    ...\n}\n\n# Train model...\nresult = cv.train(dataset, params)\n\nlogging.info('CV results: {}'.format(result))\n```\n\n\n### Assertions\n\n\n```python\nfrom pytorch_common.error import Assertions, Checker\n\n# Check functions and construtor params usign assertions..\n\nparam_value = -1\n\n# Raise an exception with 404103 eror code when the condition is not met \nAssertions.positive_int(404103, param_value, 'param name')\n\nAssertions.positive_float(404103, param_value, 'param name')\n\n# Other options\nAssertions.is_class(404205, param_value, 'param name', aClass)\n\nAssertions.is_tensor(404401, param_value, 'param name')\n\nAssertions.has_shape(404401, param_value, (3, 4), 'param name')\n\n# Assertions was impelemented using a Checker builder:\n\n Checker(error_code, value, name) \\\n    .is_not_none() \\\n    .is_int() \\\n    .is_positive() \\\n    .check()\n\n# Other checker options..\n#   .is_not_none()\n#   .is_int()\n#   .is_float()\n#   .is_positive()\n#   .is_a(aclass)\n#   .is_tensor()\n#   .has_shape(shape)\n```\n\n\n### Callbacks\n\n```python\nfrom pytorch_common.callbacks import CallbackManager\nfrom pytorch_common.modules   import FitContextFactory\n\nfrom pytorch_common.callbacks import EarlyStop, \\\n                                     ReduceLROnPlateau, \\\n                                     Validation\n\nfrom pytorch_common.callbacks.output import Logger, \\\n                                            MetricsPlotter\n\n\ndef train_method(model, epochs, optimizer, loss_fn, callbacks):\n  callback_manager = CallbackManager(\n    ctx       = FitContextFactory.create(model, loss_fn, epochs, optimizer), \n    callbacks = callbacks\n  )\n\n for epoch in range(epochs):\n            callback_manager.on_epoch_start(epoch)\n\n            # train model...\n\n            callback_manager.on_epoch_end(train_loss)\n\n            if callback_manager.break_training():\n                break\n\n  return callback_manager.ctx\n\n\nmodel     = # Create my model...\noptimizer = # My optimizer...\nloss_fn   = # my lost function\n\ncallbacks = [\n   # Log context variables after each epoch...\n   Logger(['fold', 'time', 'epoch', 'lr', 'train_loss', 'val_loss', ... ]),\n\n   EarlyStop(metric='val_auc', mode='max', patience=3),\n   \n   ReduceLROnPlateau(metric='val_auc'),\n  \n   Validation(\n       val_set,\n       metrics = {\n           'my_metric_name': lambda y_pred, y_true: # calculate validation metic,\n           ...\n       },\n       each_n_epochs=5\n   ),\n   \n   SaveBestModel(metric='val_loss'),\n   \n   MetricsPlotter(metrics=['train_loss', 'val_loss'])\n]\n\n\ntrain_method(model, epochs=100, optimizer, loss_fn, callbacks)\n```\n\n\n\n### Utils\n\n#### WeightsFileResolver\n\n```bash\n$ ls ./wegiths\n\n2023-08-21_15-17-49--gfm--epoch_2--val_loss_1.877971887588501.pt\n2023-08-21_15-13-09--gfm--epoch_3--val_loss_1.8183038234710693.pt\n2023-08-19_20-00-19--gfm--epoch_10--val_loss_0.9969356060028076.pt\n2023-08-19_19-59-39--gfm--epoch_4--val_loss_1.4990438222885132.pt\n``````\n\n```python\nimport pytorch_common.util as pu\n\nresolver = pu.WeightsFileResolver('./weights')\n\nfile_path = resolver(experiment='gfm', metric='val_loss', min_value=True)\n\nprint(file_path)\n```\n\n```bash\n'./weights/2023-08-19_20-00-19--gfm--epoch_10--val_loss_0.9969356060028076.pt'\n``````\n\n\nGo to next projects to see funcional code examples:\n\n- https://github.com/adrianmarino/deep-fm\n- https://github.com/adrianmarino/attention\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianmarino%2Fpytorch-common","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadrianmarino%2Fpytorch-common","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianmarino%2Fpytorch-common/lists"}