Skip to main content

API to compose pytorch neural networks

Project description

logo

PyPI pyversions PyPI version Code style: black

torch-composer

Compose pytorch neural networks with ease.

Installation (current version: v0.1.0)

pip install torch-composer

Sample use-cases of the API

import torch_composer
import torch

net = torch_composer.TorchNet(in_dim=2500, out_dim=10)
Sequential(
  (input): Linear(in_features=2500, out_features=200, bias=True)
  (activation_1): LeakyReLU(negative_slope=0.01)
  (hidden_1): Linear(in_features=200, out_features=200, bias=True)
  (output_activation): LeakyReLU(negative_slope=0.01)
  (output): Linear(in_features=200, out_features=10, bias=True)
)

As simple as you want (see above) or more complex with optional parameters:

torch_composer.TorchNet(
    in_dim=2500,
    out_dim=10,
    hidden={1: [800, 800], 2: [200, 200]},
    activation_function=torch.nn.LeakyReLU(negative_slope=0.01),
    dropout=0.2,
    input_bias=True,
    output_bias=True,
)
Sequential(
  (input): Linear(in_features=2500, out_features=800, bias=True)
  (activation_1): LeakyReLU(negative_slope=0.01)
  (hidden_1): Linear(in_features=800, out_features=800, bias=True)
  (dropout_1): Dropout(p=0.2, inplace=False)
  (activation_2): LeakyReLU(negative_slope=0.01)
  (hidden_2): Linear(in_features=200, out_features=200, bias=True)
  (dropout_2): Dropout(p=0.2, inplace=False)
  (output_activation): LeakyReLU(negative_slope=0.01)
  (output): Linear(in_features=200, out_features=10, bias=True)
)

Make an encoder

torch_composer.TorchNetDecoder(data_dim=2500, latent_dim=10)

Make a decoder

torch_composer.TorchNetDecoder(data_dim=2500, latent_dim=10)

Access and set initial parameters for the output layer:

torch_composer.tools.init_output_params(net)

Potential future plans

  • Composition of torch.optim funcs.

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

torch_composer-0.0.4rc0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

torch_composer-0.0.4rc0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file torch_composer-0.0.4rc0.tar.gz.

File metadata

  • Download URL: torch_composer-0.0.4rc0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for torch_composer-0.0.4rc0.tar.gz
Algorithm Hash digest
SHA256 4fa49a4af2d795ca136a8b383c293982b1fef7e8d1e5cb08f63da62fa8125744
MD5 c7dabd8e79388e7420b4b09ddbd0bfae
BLAKE2b-256 f1f2d983d4d95db17e0d8b2ba2e1310a6f038c9c02b07e2cb67c375c8e8fdee9

See more details on using hashes here.

File details

Details for the file torch_composer-0.0.4rc0-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_composer-0.0.4rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b1c0586c2c5d0e8a9f23c21aa4dd9f3e801dcf5b651f8d33e4a84637c1c9bd1
MD5 d7750f5bd3a7b5a69f59c52b9bcaf425
BLAKE2b-256 d4d04db5f861ceb5674b25a2b300709599ecdcae5da8f34a78aaadd064865abc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page