Models

Simple neural-network models used for small-scale experiments.

This module exposes four lightweight constructors — full(), conv(), logit() and linear() — that can be registered automatically by the experiments.Model loader because they are listed in __all__. Each constructor returns a ready-to-use torch.nn.Module.

Example:

>>> from experiments import Model, Configuration
>>> config = Configuration(device="cpu")
>>> model = Model("simples-full", config)
>>> output = model.run(torch.randn(4, 1, 28, 28))
experiments.models.simples.conv(*args, **kwargs)[source]

Build a small convolutional model for MNIST.

Parameters:
  • *args (object) – Forwarded to _Conv.

  • **kwargs (object) – Forwarded to _Conv.

  • Returns

  • -------

  • _Conv – A fresh convolutional model instance.

experiments.models.simples.full(*args, **kwargs)[source]

Build a small fully-connected model for MNIST.

Parameters:
  • *args (object) – Forwarded to _Full.

  • **kwargs (object) – Forwarded to _Full.

  • Returns

  • -------

  • _Full – A fresh fully-connected model instance.

experiments.models.simples.linear(*args, **kwargs)[source]

Build a simple linear model.

Parameters:
  • *args (object) – Forwarded to _Linear.

  • **kwargs (object) – Forwarded to _Linear.

  • Returns

  • -------

  • _Linear – A fresh linear model instance.

experiments.models.simples.logit(*args, **kwargs)[source]

Build a logistic-regression model.

Parameters:
  • *args (object) – Forwarded to _Logit.

  • **kwargs (object) – Forwarded to _Logit.

  • Returns

  • -------

  • _Logit – A fresh logistic-regression model instance.

See also

For the model wrapper that loads these constructors, see Model.