{"id":13738035,"url":"https://github.com/LiyuanLucasLiu/Torch-Scope","last_synced_at":"2025-05-08T15:32:18.073Z","repository":{"id":57476545,"uuid":"141640570","full_name":"LiyuanLucasLiu/Torch-Scope","owner":"LiyuanLucasLiu","description":" A Toolkit for Training, Tracking, Saving Models and Syncing Results","archived":false,"fork":false,"pushed_at":"2020-03-12T02:16:48.000Z","size":114,"stargazers_count":61,"open_issues_count":1,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-19T12:44:27.757Z","etag":null,"topics":["gpu-memory","logger","pytorch","tensorboard","toolkit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiyuanLucasLiu.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-19T23:32:21.000Z","updated_at":"2025-04-05T11:05:31.000Z","dependencies_parsed_at":"2022-09-12T15:22:47.934Z","dependency_job_id":null,"html_url":"https://github.com/LiyuanLucasLiu/Torch-Scope","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiyuanLucasLiu%2FTorch-Scope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiyuanLucasLiu%2FTorch-Scope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiyuanLucasLiu%2FTorch-Scope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiyuanLucasLiu%2FTorch-Scope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiyuanLucasLiu","download_url":"https://codeload.github.com/LiyuanLucasLiu/Torch-Scope/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252721028,"owners_count":21793746,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["gpu-memory","logger","pytorch","tensorboard","toolkit"],"created_at":"2024-08-03T03:02:09.472Z","updated_at":"2025-05-08T15:32:18.055Z","avatar_url":"https://github.com/LiyuanLucasLiu.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Torch-Scope\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Documentation Status](https://readthedocs.org/projects/tensorboard-wrapper/badge/?version=latest)](http://tensorboard-wrapper.readthedocs.io/en/latest/?badge=latest)\n[![Downloads](https://pepy.tech/badge/torch-scope)](https://pepy.tech/project/torch-scope)\n[![PyPI version](https://badge.fury.io/py/torch-scope.svg)](https://badge.fury.io/py/torch-scope)\n\nA Toolkit for training pytorch models, which has three features:\n\n- Tracking environments, dependency, implementations and checkpoints;\n- Providing a logger wrapper with two handlers (to ```std``` and ```file```);\n- Supporting automatic device selection;\n- Providing a tensorboard wrapper;\n- Providing a spreadsheet writer to automatically summarizing notes and results;\n\nWe are in an early-release beta. Expect some adventures and rough edges.\n\n## Quick Links\n\n- [Installation](#installation)\n- [Usage](#usage)\n\n## Installation\n\nTo install via pypi:\n```\npip install torch-scope\n```\n\nTo build from source:\n```\npip install git+https://github.com/LiyuanLucasLiu/Torch-Scope\n```\nor\n```\ngit clone https://github.com/LiyuanLucasLiu/Torch-Scope.git\ncd Torch-Scope\npython setup.py install\n```\n\n## Usage\n\nAn example is provided as below, please read the doc for a detailed api explaination.\n\n* set up the git in the server \u0026 add all source file to the git\n* use tensorboard to track the model stats (tensorboard --logdir PATH/log/ --port ####)\n\n```\nfrom torch_scope import wrapper\n...\nlogger = logging.getLogger(__name__)\n\nif __name__ == '__main__':\n\n    parser = argparse.ArgumentParser()\n\n    parser.add_argument('--checkpoint_path', type=str, ...)\n    parser.add_argument('--name', type=str, ...)\n    parser.add_argument('--gpu', type=str, ...)\n    ...\n    args = parser.parse_args()\n\n    pw = wrapper(os.path.join(args.checkpoint_path, args.name), name = args.log_dir, enable_git_track = False)\n    # Or if the current folder is binded with git, you can turn on the git tracking as below\n    # pw = wrapper(os.path.join(args.checkpoint_path, args.name), name = args.log_dir, enable_git_track = True)\n    # if you properly set the path to credential_path and want to use spreadsheet writer, turn on sheet tracking as below\n    # pw = wrapper(os.path.join(args.checkpoint_path, args.name), name = args.log_dir, \\\n    #             enable_git_track=args.git_tracking, sheet_track_name=args.spreadsheet_name, \\ \n    #             credential_path=\"/data/work/jingbo/ll2/Torch-Scope/torch-scope-8acf12bee10f.json\")\n    \n    \n    gpu_index = pw.auto_device() if 'auto' == args.gpu else int(args.gpu)\n    device = torch.device(\"cuda:\" + str(gpu_index) if gpu_index \u003e= 0 else \"cpu\")\n\n    pw.save_configue(args) # dump the config to config.json\n\n    # if the spreadsheet writer is enabled, you can add a description about the current model\n    # pw.add_description(args.description) \n\n    logger.info(str(args)) # would be plotted to std \u0026 file if level is 'info' or lower\n\n    ...\n\n    batch_index = 0\n\n    for index in range(epoch):\n\n    \t...\n\n    \tfor instance in ... :\n\n    \t\tloss = ...\n\n    \t\ttot_loss += loss.detach()\n    \t\tloss.backward()\n\n    \t\tif batch_index % ... = 0:\n    \t\t\tpw.add_loss_vs_batch({'loss': tot_loss / ..., ...}, batch_index, False)\n    \t\t\tpw.add_model_parameter_stats(model, batch_index, save=True)\n    \t\t\toptimizer.step()\n    \t\t\tpw.add_model_update_stats(model, batch_index)\n    \t\t\ttot_loss = 0\n    \t\telse:\n    \t\t\toptimizer.step()\n\n    \t\tbatch_index += 1\n\n    \tdev_score = ...\n    \tpw.add_loss_vs_batch({'dev_score': dev_score, ...}, index, True)\n\n    \tif dev_score \u003e best_score:\n    \t\tpw.save_checkpoint(model, optimizer, is_best = True)\n    \t\tbest_score = dev_score\n    \telse:\n    \t\tpw.save_checkpoint(model, optimizer, is_best = False)\n```\n\n## Advanced Usage\n\n### Auto Device\n\n### Git Tracking\n\n### Spreadsheet Logging\n\nShare the spreadsheet with the following account ```torch-scope@torch-scope.iam.gserviceaccount.com```. And access the table with its name. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLiyuanLucasLiu%2FTorch-Scope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLiyuanLucasLiu%2FTorch-Scope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLiyuanLucasLiu%2FTorch-Scope/lists"}