torchcnnbuilder

TorchCNNBuilder is an open-source framework for the automatic creation of CNN architectures. This framework should first of all help researchers in the applicability of CNN models for a huge range of tasks, taking over most of the writing of the architecture code. This framework is distributed under the 3-Clause BSD license. All the functionality is written only using pytorch (no third-party dependencies).

Installation

The simplest way to install framework is using pip:

pip install torchcnnbuilder

Purposes

Initially, the library was created to help predict n-dimensional time series (geodata), so there is a corresponding functionality and templates of predictive models (like ForecasterBase). Basic framework functions are presented below:

Constants

You can check current package version by using constant __version__:

from torchcnnbuilder import __version__

print(__version__)
# output: 0.1.2

Also you can check default torch convolution/transpose convolution params:

from torchcnnbuilder import DEFAULT_CONV_PARAMS, DEFAULT_TRANSPOSE_CONV_PARAMS

print(DEFAULT_CONV_PARAMS)
# output: {'kernel_size': 3, 'stride': 1, 'padding': 0, 'dilation': 1}

print(DEFAULT_TRANSPOSE_CONV_PARAMS)
# output: {'kernel_size': 3, 'stride': 1, 'padding': 0, 'output_padding': 0, 'dilation': 1}

Development

We try to maintain good practices of readable open source code. Therefore, if you want to participate in the development and open your pool request, pay attention to the following points:

  • Every push is checked by the flake8 job. It will show you PEP8 errors or possible code improvements.
  • Use this linter script in the repo root after your code:
bash lint_and_check.sh

You can mark function docstrings using #noqa, in order for flake8 not to pay attention to them.

General tips

  • If it's possible, try to create pull-requests by using fork
  • Give only appropriate names to commits / issues / pull-requests
  • It's better to use pyenv, conda or some different options of python environments in order to develop

Release process

Despite the fact that the framework is very small, we want to maintain its consistency. The release procedure looks like this:

  • pull-request is approved by maintainers and merged with squashing commits
  • a new tag is being released to the github repository
  • a new tag is being released in pypi

Building doc

Our doc is created by using pdoc framework. In order to build and serve the doc locally:

  • Install pdoc:
pip install pdoc==15.0.0
  • Run in the repo root:
pdoc --math -d google --no-include-undocumented -t .docs/ ./torchcnnbuilder
 1"""
 2**TorchCNNBuilder** is an open-source framework for the automatic creation of CNN architectures.
 3This framework should first of all help researchers in the applicability of CNN models for a huge range of tasks,
 4taking over most of the writing of the architecture code. This framework is distributed under the 3-Clause BSD license.
 5All the functionality is written only using `pytorch` *(no third-party dependencies)*.
 6
 7.. include:: ../.docs/main.md
 8"""
 9from torchcnnbuilder._constants import (
10    DEFAULT_CONV_PARAMS,
11    DEFAULT_TRANSPOSE_CONV_PARAMS,
12    MAX_PARAMS_NUMBER_PER_LAYER,
13)
14from torchcnnbuilder._formulas import (
15    conv1d_out,
16    conv2d_out,
17    conv3d_out,
18    conv_transpose1d_out,
19    conv_transpose2d_out,
20    conv_transpose3d_out,
21)
22from torchcnnbuilder._version import __version__