Borch
Getting Started | Documentation | Contributing
Borch is a universal probabilistic programming language (PPL) framework developed by Desupervised, that uses and integrates with PyTorch. Borch was designed with special attention to support Bayesian neural networks in a native fashion. Further, it's designed to
- Flexible and scalable framework
- Support neural networks out of the box.
- Have bells and whistles a universal PPL needs.
It can be installed with
pip install borch
Usage
See our full tutorials here.
As a quick example let's look into how the neural network interface looks. The
module borch.nn provides implementations of neural network modules that are
used for deep probabilistic programming and provides an interface almost
identical to the torch.nn modules. In many cases it is possible to just switch
import torch.nn as nn
to
import borch.nn as nn
and a network defined in torch is now probabilistic, without any other changes
in the model specification, one also need to change the loss function to
infer.vi.vi_loss.
For example, a convolutional neural network can be written as
import torch
import torch.nn.functional as F
from borch import nn
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(1, 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, 10)
def forward(self, x):
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))
x = F.max_pool2d(F.relu(self.conv2(x)), 2)
x = x.view(-1, self.num_flat_features(x))
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
def num_flat_features(self, x):
size = x.size()[1:]
num_features = 1
for s in size:
num_features *= s
return num_features
Installation
Borch can be installed using
pip install borch
Docker
The Borch Docker images are available as both CPU and GPU versions at gitlab.com/desupervised/borch/container_registry. The latest CPU images can be used as
docker run registry.gitlab.com/desupervised/borch/cpu:master
Contributing
Please read the contribution guidelines in CONTRIBUTING.md.
Citation
If you use this software for your research or business please cite us and help the package grow!
@misc{belcher2022borch,
title = {Borch: A Deep Universal Probabilistic Programming Language},
author = {Belcher, Lewis and Gudmundsson, Johan and Green, Michael},
year = 2022,
publisher = {arXiv},
doi = {10.48550/ARXIV.2209.06168},
url = {https://arxiv.org/abs/2209.06168},
copyright = {Creative Commons Attribution 4.0 International},
keywords = {Artificial Intelligence (cs.AI), Machine Learning (cs.LG), Programming Languages (cs.PL), FOS: Computer and information sciences, FOS: Computer and information sciences}
}
Release files for borch 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| borch-0.1.6.tar.gz | 67.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| borch-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 149.0 kB
Release files / borch-0.1.6.tar.gz
| Download URL | borch-0.1.6.tar.gz |
|---|---|
| Size | 67.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5cc4873a82a6b9af8e2777c673850a21f16b9af380f2f44695566c0c69477ef8
|
|
BLAKE2b-256 checksum How to use checksums |
df79c65599f33fdae10a06555668dbbeeb862627463f540bcae3bcf75fa39992
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / borch-0.1.6-py3-none-any.whl
| Download URL | borch-0.1.6-py3-none-any.whl |
|---|---|
| Size | 81.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3adbd05a57684e9f030f3852e6ba22983ca8b3b4db83134374b8ff13a8c13747
|
|
BLAKE2b-256 checksum How to use checksums |
c7ef88c8ba4fe25a352891d17cf89c1570523df7affc1b4b78b9c366751156c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|