Tuning the model values and gradients using PyTorch
Project description
TorchTuner
Torch tuner is a pytorch package that lets the user to register the hooks for a specific layer in a PyTorch Neural Network . This library lets you register hooks naming :
- Forward Hook
- Forward Pre-Hook
- Full Backward-Hook
- Full Backward Pre-Hook
Below are its applications after registering a hook :
1. Visualize : It saves the respective parameters that are passed into the Hook Function of that layer , as a torch tensor . Folders are created in root directory to save them .
2. Update : It lets the user to update the respective parameters that are passed into the Hook Function of that layer . The updation is done in two ways by :
-
Noise : If noise is passed then it updates the values by factor of a noise and then returns the updated values
-
Values : Return the new values if they are simply passed . When both the noise and new values are passed it will first update the new values by a factor of noise and then returns them.
As of this version you can only attach the various hooks to only a single layer by a specific instance of this library . A register method returns a handle as returned by pytorch to rmove the specific registered hook .
USAGE
VISUALIZE
Set the parameter "visualize" to True . It will automatically save the tensor .
UPDATE
To update the values whether it gradient or simple value you must set the "update" parameter to True and pass the respective values while registering a hook .
To add the noise, just register the specific hook for that layer and use it.
To update the values . Follow below steps :
- Get the shapes of that layer using the
get_shape_of_layer. It returnsinput-shapeandoutput-shape. - Create the tensor of shape
(BATCH_SIZE,respective_value). This respective_value could be theinput-shapeoroutput-shapeof that layer . This is determined by the output value the registeredHOOKreturns . If that hook returns theinputvalues which are passed in the hook function then therespective_valuewill be theinput-shapeelse if it returnsoutputvalues then it will be theoutput-shapeshape.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
torch_tuner-0.1.0.tar.gz
(5.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torch_tuner-0.1.0.tar.gz.
File metadata
- Download URL: torch_tuner-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e6249093a31693b716e6b2c75387727494ff783ac3d7a0322ea0ef2f969908f
|
|
| MD5 |
cb5e1e20e79d536edabc3387d5b213df
|
|
| BLAKE2b-256 |
fff226096862532b4a90326854f5916edf779bb0dd249a720c999b9c3d3207db
|
File details
Details for the file torch_tuner-0.1.0-py3-none-any.whl.
File metadata
- Download URL: torch_tuner-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
921992c3c22efe248e453028d4b617d9b95df04a84df3296e86fdf9cfe39d969
|
|
| MD5 |
904ed2d54e63fc6ec32f889dbf07bfcf
|
|
| BLAKE2b-256 |
34c33d7d40e468ef5b2dca2197282b8e80c573f2b7194b5bc4086f24123aa182
|