https://github.com/cschoeller/pycandle
Lightweight library for executing PyTorch experiments without boilerplate code.
https://github.com/cschoeller/pycandle
deep-learning machine-learning neural-networks python pytorch
Last synced: 3 months ago
JSON representation
Lightweight library for executing PyTorch experiments without boilerplate code.
- Host: GitHub
- URL: https://github.com/cschoeller/pycandle
- Owner: cschoeller
- License: mit
- Created: 2019-03-11T11:24:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-17T22:10:36.000Z (about 3 years ago)
- Last Synced: 2026-02-11T21:29:22.321Z (5 months ago)
- Topics: deep-learning, machine-learning, neural-networks, python, pytorch
- Language: Python
- Homepage:
- Size: 85.9 KB
- Stars: 17
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

PyCandle is a lightweight library for pytorch that makes running experiments easy, structured, repeatable and avoids boilerplate code. It maintains flexibilty and allows to train also more complex models like recurrent or generative neural networks conveniently.
### Usage
This code snippet creates a timestamped directory for the current experiment, runs the training of the model, creates a backup of all used code, logs current git hash and forks console output into a log file:
```python
model = Net().cuda()
experiment = Experiment('mnist_example')
train_loader = load_dataset(batch_size_train=64)
optimizer = torch.optim.Adam(model.parameters(), lr=0.01)
model_trainer = ModelTrainer(model, optimizer, F.nll_loss, 20, train_loader, device=0)
model_trainer.start_training()
```
A complete example for training a model to classify hand-written MNIST digits can be found in [minimal_example/mnist.py](minimal_example/mnist.py).
### Installation
Using PyCandle is very simple: Clone the repository anywhere on your machine and then create symlink with `ln -s ` in your machine learning project that points to the pycandle folder. Then you can just include modules with `import pycandle.*`. This is also how we use it in our example.
Alternatively, it is now possible to install PyCandle with pip:
`pip3 install pycandle`
### Requirements
We tested PyCandle with the dependency versions listed here. However, PyCandle can also work with newer versions if they are downward compatible.
* Python >= 3.5
* PyTorch >= 1.2
* numpy >= 1.16.4
* torchvision >= 0.2.1 (for examples)
* matplotlib >= 2.1.1 (for examples)