Skip to content

Commit

Permalink
changed code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarnerides committed Jan 29, 2018
1 parent cb76211 commit c206837
Showing 1 changed file with 61 additions and 62 deletions.
123 changes: 61 additions & 62 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,113 +20,112 @@ Features

- **Trainers** (currently Vanilla, VanillaGAN, WGAN-GP, BEGAN, FisherGAN)

.. code:: python3
trainer = dlt.train.VanillaGANTrainer(generator, discriminator, g_optim, d_optim)
for batch, (prediction, losses) in trainer(data_loader):
# Training happens in the iterator and relevant results are returned for each step
```python
trainer = dlt.train.VanillaGANTrainer(generator, discriminator, g_optim, d_optim)
for batch, (prediction, losses) in trainer(data_loader):
# Training happens in the iterator and relevant results are returned for each step
```
- Built in configurable **parser** with arguments.

.. code:: python3
opt = dlt.config.parse() # Has built in options (can add extra)
print('Some Settings: ', opt.experiment_name, opt.batch_size, opt.lr)
```python
opt = dlt.config.parse() # Has built in options (can add extra)
print('Some Settings: ', opt.experiment_name, opt.batch_size, opt.lr)
```

- **Configuration files** support and parser compatible functions.

.. code:: bash
$ python main.py @settings.cfg
Some Settings: config_test 32 0.0001
```bash
$ python main.py @settings.cfg
Some Settings: config_test 32 0.0001
```

- **HDR imaging** support (.hdr, .exr, and .pfm formats)

.. code:: python3
img = dlt.hdr.imread('test.pfm')
dlt.hdr.imwrite('test.exr', img)
```python
img = dlt.hdr.imread('test.pfm')
dlt.hdr.imwrite('test.exr', img)
```

- **Checkpointing** of (torch serializable) objects; Network state dicts supported.

.. code:: python3
data_chkp = Checkpointer('data')
data_chkp.save(np.array([1,2,3]))
a = data_chkp.load()
```python
data_chkp = Checkpointer('data')
data_chkp.save(np.array([1,2,3]))
a = data_chkp.load()
```

- **Image operations** and easy conversions between multiple library views (torch, cv, plt)

.. code:: python3
img = cv2.imread('image.jpg') # Height x Width x Channels - BGR
dlt.viz.imshow(img, view='cv') # Height x Width x Channels - RGB
tensor_with_torch_view = cv2torch(img) # Channels x Height x Width - RGB
```python
img = cv2.imread('image.jpg') # Height x Width x Channels - BGR
dlt.viz.imshow(img, view='cv') # Height x Width x Channels - RGB
tensor_with_torch_view = cv2torch(img) # Channels x Height x Width - RGB
```

- Easy **visualization** (and make_grid supporting Arrays, Tensors, Variables and lists)

.. code:: python3
for batch, (prediction, loss) in trainer(loader):
grid = dlt.util.make_grid([ batch[0], batch[1], prediction], size(3, opt.batch_size))
dlt.viz.imshow(grid, pause=0.01, title='Training Progress')
```python
for batch, (prediction, loss) in trainer(loader):
grid = dlt.util.make_grid([ batch[0], batch[1], prediction], size(3, opt.batch_size))
dlt.viz.imshow(grid, pause=0.01, title='Training Progress')
```

- Model parameter and layer input/outputs/gradients visualization.

.. code:: python3
net = nn.Sequential(nn.Linear(10, 10))
dlt.viz.modules.forward_hook(net, [nn.Linear], tag='layer_outputs', histogram=False)
net(Variable(torch.Tensor(3,10)))
```python
net = nn.Sequential(nn.Linear(10, 10))
dlt.viz.modules.forward_hook(net, [nn.Linear], tag='layer_outputs', histogram=False)
net(Variable(torch.Tensor(3,10)))
```

- CSV **Logger**.

.. code:: python3
log = dlt.util.Logger('losses', ['train_loss', 'val_loss'])
log({'train_loss': 10, 'val_loss':20})
```python
log = dlt.util.Logger('losses', ['train_loss', 'val_loss'])
log({'train_loss': 10, 'val_loss':20})
```

- Command line tool for easy **plotting** of CSV files (with live updating).

.. code:: bash
$ dlt-plot --file losses.csv train_loss val_loss --refresh 5 --loglog True --tail 100
```bash
$ dlt-plot --file losses.csv train_loss val_loss --refresh 5 --loglog True --tail 100
```

- A minimal **Progress bar** (with global on/off switch).

.. code:: python3
from dlt.util import barit
barit.silent = False # Default is False
for batch in barit(loader, start='Loading'):
pass
```python
from dlt.util import barit
barit.silent = False # Default is False
for batch in barit(loader, start='Loading'):
pass
```

Installation
---------------------

Make sure you have PyTorch_ installed. OpenCV is also required:

.. code:: bash
conda install -c menpo opencv
```bash
conda install -c menpo opencv
```

conda install (recommended):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: bash

conda install -c demetris pydlt
```bash
conda install -c demetris pydlt
```

From source:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: bash
git clone https://github.com/dmarnerides/pydlt.git
cd pydlt
python setup.py install
```bash
git clone https://github.com/dmarnerides/pydlt.git
cd pydlt
python setup.py install
```

About
--------
Expand Down

0 comments on commit c206837

Please sign in to comment.