Provides symbolic API for model creation in PyTorch.
Project description
Pytorch Symbolic
Pytorch Symbolic is MIT licensed library that adds symbolic API for model creation to PyTorch.
Pytorch Symbolic makes it easier and faster to define complex models. It spares you writing boilerplate code. It aims to be PyTorch equivalent for Keras Functional API.
Features:
- Small extension of PyTorch
- No dependencies besides PyTorch
- Produces models entirely compatible with PyTorch
- Overhead free as tested in benchmarks
- Reduces the amount of boilerplate code
- Works well with complex architectures
- Code and documentation is automatically tested
Example
To create a symbolic model, you need Symbolic Tensors and torch.nn.Module
.
Register layers and operations in your model by calling layer(inputs)
or
equivalently inputs(layer)
.
Layers will be automagically added to your model and
all operations will be replayed on the real data.
That's all!
Using Pytorch Symbolic, we can define a working classifier in a few lines of code:
from torch import nn
from pytorch_symbolic import Input, SymbolicModel
inputs = Input(shape=(1, 28, 28))
x = nn.Flatten()(inputs)
x = nn.Linear(x.shape[1], 10)(x)(nn.Softmax(1))
model = SymbolicModel(inputs=inputs, outputs=x)
model.summary()
_______________________________________________________
Layer Output shape Params Parent
=======================================================
1 Input_1 (None, 1, 28, 28) 0
2 Flatten_1 (None, 784) 0 1
3 Linear_1 (None, 10) 7850 2
4* Softmax_1 (None, 10) 0 3
=======================================================
Total params: 7850
Trainable params: 7850
Non-trainable params: 0
_______________________________________________________
See more examples in Documentation Quick Start.
Gentle introduction
There's a jupyter notebook showing the basic usage of Pytorch Symbolic. With it you will:
- Learn Pytorch Symbolic in an interactive way
- Try the package before installing it on your computer
- See visualizations of graphs that are created under the hood
Installation
Install Pytorch Symbolic easily with pip:
pip install pytorch-symbolic
Links
Create an issue if you noticed a problem!
Send me an e-mail if you want to get involved: sjmikler@gmail.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pytorch-symbolic-1.0.7.tar.gz
.
File metadata
- Download URL: pytorch-symbolic-1.0.7.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75a1f36596927b6d4da14f97388b4b94f35d67c2cdf7b0ba021b77a0040be423 |
|
MD5 | b2003173739113deb5dbcf4b68abced1 |
|
BLAKE2b-256 | cbb8199bc6b67cf1e5f39a0e3a991e2f1bcd2991fe52c3a4bebd61ccaa4998aa |