Package: pyklopp
pykloppTired of logging all hyperparameter configurations of your model prototyping to disk?Pyklopp is a tool to initialize, train and evaluate pytorch models (currently for supervised problems).
It persists all relevant hyperparameters, timings and model configurations.
Your prototyping is reduced to defining your model, the dataset and your desired parameters.Important note:we are undergoing an architectural change from writing config json files to writing meta data files given a jsonschema.
So to keep your experiments reproducible and program against a current design of pyklopp, reference the exact pyklopp version in your experiment.
E.g. for yourenvironment.yml:dependencies:-pip:-pyklopp==0.3.0InstallationYou can install a version from PyPi with:pip install pyklopp.To install the latest development build, you can clone the repository and invokepoetry build(having poetry installed).
Then you can use the built package and install it with pip in your current environment bypip install dist/xxx.whl.Defining model & datasetUsed imports:importpypaddle.sparseimportpypaddle.utilimporttorch.nnasnnimporttorch.nn.functionalasFSpecify your model in a plain python file, e.g.:# my_model.py# Your model can be any pytorch module# Make sure to not define it locally (e.g. within the get_model()-function)classLeNet(nn.Module):def__init__(self,output_size):super(LeNet,self).__init__()self.conv1=nn.Conv2d(3,6,5)self.conv2=nn.Conv2d(6,16,5)self.fc1=nn.Linear(16*5*5,120)self.fc2=nn.Linear(120,84)self.fc3=nn.Linear(84,output_size)defforward(self,x):out=F.relu(self.conv1(x))out=F.max_pool2d(out,2)out=F.relu(self.conv2(out))out=F.max_pool2d(out,2)out=out.view(out.size(0),-1)out=F.relu(self.fc1(out))out=F.relu(self.fc2(out))out=self.fc3(out)returnout# This is your model-instantiation function# It receives an assembled configuration keyword argument list and should return an instance of your modeldefget_model(**kwargs):output_size=int(kwargs['output_size'])returnLeNet(output_size)Invoke pyklopp to initialize it:pyklopp init my_model.get_model --save='test/model.pth' --config='{"output_size": 10}'Train it oncifar10:pyklopp train test/model.pth cifar10.py --save='test/trained.pth' --config='{"batch_size": 100}'pyklopp train test/model.pth torchvision.datasets.cifar.CIFAR10 --save 'test/trained.pth' --config='{"dataset_root": "/media/data/set/cifar10"}'Examples# Initializing & Saving: mymodel.pypykloppinitfoo--save='mymodel1/model.pth'pykloppinitfoo--config='{"python_seed_initial": 100}'--save='mymodel2/model.pth'# Trainingpyklopptrainpath/to/mymodel.pthmnist
pyklopptrainpath/to/mymodel.pthmnist--config='{"batch_size": 100, "learning_rate": 0.01}'# foo.py - Your model initialization functiondefinit(**kwargs):input_size=kwargs['input_size']output_size=kwargs['output_size']returnpypaddle.sparse.MaskedDeepFFN(input_size,output_size,[100,100])# mnist.py - Your dataset loading functionsdeftrain_loader(**kwargs):batch_size=kwargs['batch_size']mnist_train_loader,mnist_test_loader,_,selected_root=pypaddle.util.get_mnist_loaders(batch_size,'/media/data/set/mnist')returnmnist_train_loaderdeftest_loader(**kwargs):batch_size=kwargs['batch_size']mnist_train_loader,mnist_test_loader,_,selected_root=pypaddle.util.get_mnist_loaders(batch_size,'/media/data/set/mnist')returnmnist_test_loaderDevelopmentCreate wheel files indist/:poetry buildInstall wheel in current environment with pip:pip install path/to/pyklopp/dist/pyklopp-0.1.0-py3-none-any.whlRunning CI image locallyInstall latestgitlab-runner(version 12.3 or up):# For Debian/Ubuntu/Mintcurl-Lhttps://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh|sudobash# For RHEL/CentOS/Fedoracurl-Lhttps://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh|sudobash

apt-getupdate
apt-getinstallgitlab-runner

$gitlab-runner-v
Version:12.3.0Execute jobtests:gitlab-runner exec docker test-python3.6Running github action locallyInstallhttps://github.com/nektos/act.
RunactRunning pre-commit checks locallypoetry run pre-commit run --all-files