{"id":17606390,"url":"https://github.com/atcold/torch-torch7-tools","last_synced_at":"2025-04-30T12:20:39.321Z","repository":{"id":73551402,"uuid":"13099575","full_name":"Atcold/torch-Torch7-tools","owner":"Atcold","description":"This would be a collection of useful routines and function currently missing in Torch7","archived":false,"fork":false,"pushed_at":"2014-05-29T18:43:02.000Z","size":258,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-30T16:05:44.288Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Atcold.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2013-09-25T16:51:06.000Z","updated_at":"2025-03-02T15:41:47.000Z","dependencies_parsed_at":"2023-02-23T13:01:05.609Z","dependency_job_id":null,"html_url":"https://github.com/Atcold/torch-Torch7-tools","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/Atcold%2Ftorch-Torch7-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atcold%2Ftorch-Torch7-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atcold%2Ftorch-Torch7-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atcold%2Ftorch-Torch7-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atcold","download_url":"https://codeload.github.com/Atcold/torch-Torch7-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251700490,"owners_count":21629837,"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":[],"created_at":"2024-10-22T15:44:23.604Z","updated_at":"2025-04-30T12:20:39.260Z","avatar_url":"https://github.com/Atcold.png","language":"Lua","readme":"# Torch7-tools\n\nThis would be a collection of useful routines and function currently missing in [`Torch7`](https://github.com/torch/torch7).  \nMost of the time the scripts are just usefull routines or functions I am using for my job and I am allowed to extract and publish here.\n\n## Tools description\n\n### Table of contents\n - [Network lightener](#network-lightener)\n - [Gradient repopulation](#gradient-repopulation)\n - [Command line parser](#command-line-parser)\n - [Cuda to Float network converter](#cuda-to-float-network-converter)\n\n### Important!\nThe new [`net-toolkit`](https://github.com/Atcold/net-toolkit/tree/master) Torch7 package will be released soon. Basically it will provide a way for easily handling networks and it will include the following two functions, which are to be considered therefore deprecated.\n\n\u003e ### Network lightener\n\u003e `netLighter` library provides a `saveNet(name, network)` function which saves a lighter version of your current network, removing all unnecessary data from it (such as *gradients*, *temporal data* and etc...). The default location is `./`; if a different one is preferred instead, you may want to specify it with a global option `opt.save = 'my-path/'`. Usage:\n\n\u003e ```lua\n\u003e -- if './' is not ok:\n\u003e opt = opt or {}\n\u003e opt.save = 'my-path/'\n\u003e -- otherwise, it will be sufficient only:\n\u003e require 'netLighter'\n\u003e -- net = nn.Sequential() and other stuff\n\u003e saveNet('myNet.net',net)\n\u003e ```\n\n\u003e ### Gradient repopulation\n\u003e Let's say we would like to load a network we have previously saved with `saveNet()` for continuing a training \u003e session on it. Some inner parameters (something about *gradients*) have to be restored, since `saveNet()` did a pruning operation on the network in order to save space. Here is how we can handle this case:\n\n\u003e ```lua\n\u003e local networkFile = '/path/To/MyNet.net'\n\u003e model = torch.load(networkFile)\n\u003e repopulateGrad(model)\n\u003e ```\n\n\u003e Now we can keep training, perhaps without forgetting to define a *criterion* `loss` (the criterion is not saved with the network, so we have to re-define it, if we don't already do it somewhere else in the code).\n\n### Command line parser\n`penlightTest` shows a great deal of command line parser options that could turn helpful when we need to send some initial configuration values to the script in a compact manner. Running the script in `lua` (or `torch`) with no argument will print on screen the help screen (usually reachable with the option `--help` or `-h`, which in **this** case has been deliberately overwritten to be the `height` handle).\n```bash\nlua penlightTest.lua\n```\nMoreover, you can notice the presence of `default false` and `default true` flags and short *multi-letter* handles as well, which are not iterpreted as in the Unix environment (say like `ls -al`) because of `slack = true` of `lapp` has been (intentionally) set to `true`.\nYou can run the test like this (it will show everything it can do that I care)\n```bash\nlua penlightTest.lua -v abc --time 40 -h 20 -sk 15 --flag1 -f3\n```\nThe same two lines above could have been written by sustituting `lua` with `torch` (and this is what I usually do). Further documentation on the `lapp` command line parser can be found [here](https://github.com/stevedonovan/Penlight/blob/master/doc/manual/08-additional.md#command-line-programs-with-lapp).\n\n### Cuda to Float network converter\n`netConverter` converts a `cuda` network into an equivalent `float` one.\n```bash\n./netConverter.lua ../results/multinet-cuda.net\n```\nThe scripts automatically changes the extension to `-float.net` and saves the new network in the same location of the input one (which is specified as argument of the routine, as you can see from the example above).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatcold%2Ftorch-torch7-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatcold%2Ftorch-torch7-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatcold%2Ftorch-torch7-tools/lists"}