Quickly, with very little code, create PyTorch Lightning models
Project description
Lightning Factory
Lightning Factory is a Python library designed to simplify the creation of PyTorch Lightning models for various types of neural networks. It follows the parameterized factory pattern and allows users to specify custom configurations or use common defaults for quick prototyping.
Usage
pip install lightning_factory
To create a feed-forward neural network model:
import lightning_factory as lf
model = lf.ffnn(layers=[5, 3, 3, 1])
Easily define the layer structure:
Set default parameters when constructing the factory:
from lightning_factory import LightningFactory
from lightning_factory import LossFunction
from lightning_factory import ActivationFunction
lf = LightningFactory(
loss_function=LossFunction.MSE,
batch_size=32,
activation_function=ActivationFunction.Softplus
)
model1 = lf.ffnn(layers=[5,3,3,1])
model2 = lf.ffnn(layers=[5,8,4,2,1], activation_function=ActivationFunction.Tanh)
The LightningFactory
class uses the following defaults when making a class:
default = {
'layers': None,
'learning_rate': 0.001,
'max_epochs': 8,
'batch_size': 64,
'loss_function': 'BCE',
'activation_function': 'ReLU',
'optimizer': 'Adam',
'dropout': 0,
'l1_regularization': 0,
'l2_regularization': 0,
'weight_initialization': 'xavier_uniform'
}
Testing Coverage
Name | Stmts | Miss | Branch | BrPart | Cover | Missing |
---|---|---|---|---|---|---|
lightning_factory/LightningFactory.py | 18 | 0 | 8 | 0 | 100% | |
lightning_factory/__init__.py | 3 | 0 | 0 | 0 | 100% | |
lightning_factory/create_ffnn.py | 41 | 29 | 14 | 0 | 22% | 19-30, 34-36, 40-46, 50-59, 63-71 |
lightning_factory/enums.py | 121 | 0 | 18 | 0 | 100% | |
lightning_factory/functions.py | 4 | 2 | 0 | 0 | 50% | 6-7 |
TOTAL | 187 | 31 | 40 | 0 | 80% |
To run a coverage report
coverage report --format=markdown
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lightning_factory-0.1.0.tar.gz
(108.3 kB
view hashes)
Built Distribution
Close
Hashes for lightning_factory-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28c375332fe8c7c02619f12b8732104dbacac49e8c78b1ba8bd551f945fb5478 |
|
MD5 | e9733579daa7866a6f377a03b5fb50cf |
|
BLAKE2b-256 | 365d880fbfa5364b20ebcc5841a5419e7253ecf8290184463a78e44aa0200c63 |