{"id":17606404,"url":"https://github.com/atcold/torch-net-toolkit","last_synced_at":"2025-04-30T12:21:08.528Z","repository":{"id":15568335,"uuid":"18303680","full_name":"Atcold/torch-net-toolkit","owner":"Atcold","description":"A simple module for \u003cTorch7\u003e and the \u003cnn\u003e package","archived":false,"fork":false,"pushed_at":"2015-04-30T13:57:43.000Z","size":270,"stargazers_count":18,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T16:06:00.036Z","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":null,"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":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-31T18:34:21.000Z","updated_at":"2025-03-02T15:41:47.000Z","dependencies_parsed_at":"2022-09-12T07:20:40.527Z","dependency_job_id":null,"html_url":"https://github.com/Atcold/torch-net-toolkit","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-net-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atcold%2Ftorch-net-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atcold%2Ftorch-net-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atcold%2Ftorch-net-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atcold","download_url":"https://codeload.github.com/Atcold/torch-net-toolkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251700650,"owners_count":21629841,"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:25.025Z","updated_at":"2025-04-30T12:21:08.475Z","avatar_url":"https://github.com/Atcold.png","language":"Lua","readme":"# net-Toolkit\n\nA simple module for [`Torch7`](https://github.com/torch/torch7) and the [`nn` package](https://github.com/torch/nn).\n\n## Installation\n\n```bash\nluarocks install --server=https://raw.github.com/Atcold/net-toolkit/master net-toolkit\n```\n\n## Description\n\nThe package `net-toolkit` allows to save and retrive to/from disk a lighter version of the network that is being training. After `require('net-toolkit')`, you will have the following functions at your disposal:\n\n - [`netToolkit.saveNet()`](#savenet)\n - [`netToolkit.saveNetFields()`](#savenetfields)\n - [`netToolkit.loadNet()`](#loadnet)\n\n### `saveNet()`\n\n`saveNet()` saves a lighter version of your current network, removing all unnecessary data from it (such as *gradients*, *activation units*' state and etc...) and returns a new couple of flattened *weights* and *gradients*. Usage:\n\n```lua\nw, dw = saveNet(fileName, model)\n```\n\nIf you want to save the model in `ascii` format, call `saveNet()` as shown below. The output file will have an `.ascii` extension appended to `fileName`.\n\n```lua\nw, dw = saveNet(fileName, model, 'ascii')\n```\n\n### `saveNetFields()`\n\n`saveNetFields()` saves your current network, removing all `Tensor` data you don't want to save and returns a new couple of flattened *weights* and *gradients*. (Set `format` to `'ascii'` for saving in `ascii` format.) Usage:\n\n```lua\nw, dw = saveNetFields(fileName, model, {'weight', 'bias'}, format)\n```\n\nIn this case, only `weight` and `bias` `Tensor`s will be saved while the rest will be discarded. (The function `saveNet()` is, therefore, a shortcut to this specific usage of `saveNetFields()`.) However, we could have saved also `gradWeight` and `gradBias` by doing:\n\n```lua\nw, dw = saveNetFields(fileName, model, {'weight', 'bias', 'gradWeight', 'gradBias'}, format)\n```\n\n### `loadNet()`\n\nLet's say we would like to load a network we have previously saved with `saveNet()` for continuing a training 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. (Set `format` to `'ascii'` if you are trying to load a `.ascii` net. `fileName` does not have to include the `.ascii` extenstion.) Here is how we can handle this case:\n\n```lua\nmodel, w, dw = loadNet(fileName, format)\n```\n\nNow we can keep training, perhaps without forgetting to (re-)define a [*criterion* `loss`](https://github.com/torch/nn/blob/master/README.md#criterions) (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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatcold%2Ftorch-net-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatcold%2Ftorch-net-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatcold%2Ftorch-net-toolkit/lists"}