Deep Learning framework for fast and clean research development with Pytorch
Project description
Kerosene
Deep Learning framework for fast and clean research development with Pytorch - see the doc for more details.
MNIST Example
Here is a simple example that shows how easy and clean it is to train a simple network. In very few lines of code, the model is trained using mixed precision and you got Visdom + Console logging automatically. See full example there: MNIST-Kerosene
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
CONFIG_FILE_PATH = "config.yml"
model_trainer_config, training_config = YamlConfigurationParser.parse(CONFIG_FILE_PATH)
train_loader = DataLoader(torchvision.datasets.MNIST('./files/', train=True, download=True, transform=Compose(
[ToTensor(), Normalize((0.1307,), (0.3081,))])), batch_size=training_config.batch_size_train, shuffle=True)
test_loader = DataLoader(torchvision.datasets.MNIST('./files/', train=False, download=True, transform=Compose(
[ToTensor(), Normalize((0.1307,), (0.3081,))])), batch_size=training_config.batch_size_valid, shuffle=True)
# Initialize the loggers
visdom_logger = VisdomLogger(VisdomConfiguration.from_yml(CONFIG_FILE_PATH))
# Initialize the model trainers
model_trainer = ModelTrainerFactory(model=SimpleNet()).create(model_trainer_config, RunConfiguration(use_amp=False))
# Train with the training strategy
trainer = SimpleTrainer("MNIST Trainer", train_loader, test_loader, model_trainer) \
.with_event_handler(PrintTrainingStatus(every=100), Event.ON_BATCH_END) \
.with_event_handler(PrintModelTrainersStatus(every=100), Event.ON_BATCH_END) \
.with_event_handler(PlotAllModelStateVariables(visdom_logger), Event.ON_EPOCH_END) \
.with_event_handler(PlotGradientFlow(visdom_logger, every=100), Event.ON_TRAIN_BATCH_END) \
.train(training_config.nb_epochs)
Contributing
How to contribute ?
- Create a branch by feature and/or bug fix
- Get the code
- Commit and push
- Create a pull request
Branch naming
Feature branch
feature/ [Short feature description] [Issue number]
Bug branch
fix/ [Short fix description] [Issue number]
Commits syntax:
Adding code:
+ Added [Short Description] [Issue Number]
Deleting code:
- Deleted [Short Description] [Issue Number]
Modifying code:
* Changed [Short Description] [Issue Number]
Merging code:
Y Merged [Short Description] [Issue Number]
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.