https://github.com/dfdx/lilith.jl
Renamed to Avalon.jl
https://github.com/dfdx/lilith.jl
Last synced: about 1 year ago
JSON representation
Renamed to Avalon.jl
- Host: GitHub
- URL: https://github.com/dfdx/lilith.jl
- Owner: dfdx
- Created: 2019-09-14T14:01:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-09T23:18:58.000Z (over 5 years ago)
- Last Synced: 2025-03-01T10:11:13.732Z (over 1 year ago)
- Language: Jupyter Notebook
- Homepage:
- Size: 140 KB
- Stars: 44
- Watchers: 5
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lilith
> :warning: **This package has been renamed to [Avalon.jl](https://github.com/dfdx/Avalon.jl), all new features will be added there**
[](https://travis-ci.org/dfdx/Lilith.jl)
**Lilith** is a deep learning library in Julia with focus on **high performance** and **interoperability with existing DL frameworks**. Its main features include:
* tracing autograd engine - models are just structs, transformations are just functions
* optimizing code generator based on hackable computational graph
* GPU support
* layer API similar to PyTorch's to ease translation of existing Python code to Julia
* high backward compatibility to allow accumulation of models
## Usage
To get you a feeling of what Lilith is like, here's a definition of a small convolutional neural network:
```julia
using Lilith
mutable struct Net
conv1::Conv2d
conv2::Conv2d
fc1::Linear
fc2::Linear
end
Net() = Net(
Conv2d(1, 20, 5),
Conv2d(20, 50, 5),
Linear(4 * 4 * 50, 500),
Linear(500, 10)
)
function (m::Net)(x::AbstractArray)
x = maxpool2d(relu.(m.conv1(x)), (2, 2))
x = maxpool2d(relu.(m.conv2(x)), (2, 2))
x = reshape(x, 4*4*50, :)
x = relu.(m.fc1(x))
x = logsoftmax(m.fc2(x))
return x
end
```
For detailed explanation of this and other models see [the tutorial](https://github.com/dfdx/Lilith.jl/tree/master/tutorial). Some predefined models are also available in [the zoo](https://github.com/dfdx/Lilith.jl/tree/master/zoo).
## Performance
Performance comparison between different libraries is hard and benchmarks are rarely fair, but here's our best shot in this direction:
### Convolutional neural network
Code available [here](https://github.com/dfdx/Lilith.jl/tree/master/benchmarks/cnn)
| | training 1 epoch | training total time* | prediction |
| ------------- | ---------------- | -------------------- | ---------- |
| Lilith (CPU) | 170 s | 1742 s | 39 ms |
| Flux (CPU) | 250 s | 2515 s | 42 ms |
| ------------- | ---------------- | -------------------- | ---------- |
| Lilith (GPU) | 10 s | 164 s | 5 ms |
| Flux (GPU) | 12 s | 150 s | 5 ms |
| PyTorch (GPU) | 12 s | 120 s | 2 ms |
`*` - total time includes 10 epochs + compilation time
Note that in the test on GPU Lilith has longest compilation time and thus
longest total training time _after 10 epochs_. However, time per epoch
is the lowest, so Lilith is typically the fastest one in longer run.
### Variational Autoencoder
Code available [here](https://github.com/dfdx/Lilith.jl/tree/master/benchmarks/vae)
| | training 1 epoch | training total time | prediction |
| ------------- | ---------------- | -------------------- | ---------- |
| Lilith (CPU) | 50 s | 535 s | 395 μs |
| Flux (CPU) | 948 s | 158 min | 81 ms |
| ------------- | ---------------- | -------------------- | ---------- |
| Lilith (GPU) | 3 s | 93 s | 194 μs |
| Flux (GPU)** | --- | --- | --- |
| PyTorch (GPU) | 7 s | 66 s | 501 µs |
`**` - VAE example from the Flux zoo doesn't work on GPU
## API Stability
One of the central ideas behind Lilith is the ability to reuse existing code instead of writing everything from scratch.
To facilitate it, Lilith is committed to high, although not absolute backward compatibility. The following table
outlines stability level you should expect from various components of the library.
| Component | API Stable? |
| --------------- | ----------- |
| Basic layers | Yes |
| CNN | Yes |
| RNN | No* |
| Losses | Mostly |
| Activations | Yes |
| Initializations | Mostly |
| Optimizers | Yes |
| Device API | Yes |
| Fitting API | No** |
`*` - currently Lilith provides only basic implementations of vanilla RNN, LSTM and GRU; this implementation will be improved in future version and made more compatible with PyTorch version, but currently it cannot be considered stable
`**` - function `fit!()` provides a convenient shortcut for training supervised learning models, but in its current state it's too basic for most real use cases; for more durable code consider writing your own method for training using `fit!()` as a template
Please note that until version 1.0 "stable API" means that we will try our best to keep it unchanged, but we reserve the right to the break the rule in some rare and exceptional cases.