LocoProp implementation in PyTorch.
Project description
LocoProp Torch
Implementation of the paper "LocoProp: Enhancing BackProp via Local Loss Optimization" in PyTorch.
Paper: https://proceedings.mlr.press/v151/amid22a/amid22a.pdf
Official code: https://github.com/google-research/google-research/blob/master/locoprop/locoprop_training.ipynb
Installation
pip install locoprop
Usage
from locoprop import LocoLayer LocopropTrainer
# model needs to be instance of nn.Sequential
# each trainable layer needs to be instance of LocoLayer
# Example: deep auto-encoder
model = nn.Sequential(
LocoLayer(nn.Linear(28*28, 1000), nn.Tanh()),
LocoLayer(nn.Linear(1000, 500), nn.Tanh()),
LocoLayer(nn.Linear(500, 250), nn.Tanh()),
LocoLayer(nn.Linear(250, 30), nn.Tanh()),
LocoLayer(nn.Linear(30, 250), nn.Tanh()),
LocoLayer(nn.Linear(250, 500), nn.Tanh()),
LocoLayer(nn.Linear(500, 1000), nn.Tanh()),
LocoLayer(nn.Linear(1000, 28*28), nn.Sigmoid(), implicit=True), # implicit means the activation only is applied during local optimization
)
def loss_fn(logits, labels):
...
trainer = LocopropTrainer(model, loss_fn)
dl = get_dataloader()
for x, y in dl:
trainer.step(x, y)
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
locoprop-0.1.0.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file locoprop-0.1.0.tar.gz
.
File metadata
- Download URL: locoprop-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5b231462d8ade9c0131bdee1416f2c8676b16085bd9ad4c219306bcad1435fa |
|
MD5 | fc8e33cefde230da93944372e0a1b3d2 |
|
BLAKE2b-256 | 90ade6fac6a5f65028db3fd95d265b27e30834a89736a69cf99895240cb9aedc |
File details
Details for the file locoprop-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: locoprop-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b104e3ca4fa22384aaba894d925fb7adf4bf1db47ea101c483fb1d87f26f138 |
|
MD5 | b79bd8e9755248a0c7a9e7beaa2a9906 |
|
BLAKE2b-256 | e27b607b5559f152edc32c40d95cfc74255e63d018d83f3e0d8c9b76ae81d47a |