Minimal torch/numpy agnostic relational function.
Project description
A Minimal Relational Function
PyTorch/Numpy agnostic function implementing the relational block from "A simple neural network module for relational reasoning".
I wrote this to learn how to use nbdev. I'm pretty sure it's correct but it only implements the core function for using relational networks and none of the other stuff (such as nn.Module classes etc) that Kai included in the pull request.
The original paper can be found here.
Install
pip install relational
How to use
This can be used to implement a relational network in PyTorch. An example would be something like:
from relational.core import relation
import torch
import torch.nn as nn
class SetNet(nn.Module):
def __init__(self, datadim, n_hidden):
super(SetNet, self).__init__()
self.n_hidden = n_hidden
self.g = nn.Sequential(nn.Linear(datadim*2, n_hidden),
nn.ReLU(),
nn.Linear(n_hidden, n_hidden))
self.f = nn.Sequential(nn.Linear(n_hidden, n_hidden),
nn.ReLU(),
nn.Linear(n_hidden, n_hidden))
def forward(self, x):
n, t, d = x.size()
x = relation(x, self.g, reduction='mean')
return self.f(x)
x = torch.randn(4, 8, 16)
setnet = SetNet(x.size(2), 10)
setnet(x).size()
torch.Size([4, 10])
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file relational-0.0.1.tar.gz.
File metadata
- Download URL: relational-0.0.1.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d59d45465b39380ed1b6f4a5c272aa9c5f32fa59cf7c9615eacfa1334be704f
|
|
| MD5 |
c477ed4527ad497f25e1f2dda7d37934
|
|
| BLAKE2b-256 |
06a1124e6f45d9a88c8168fef64ed54b0d40131eebb075106a18c0420d4d5a27
|
File details
Details for the file relational-0.0.1-py3-none-any.whl.
File metadata
- Download URL: relational-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
888003da117b268c1acd13dec8a0d1ad267165994a542f79cd64c28ca3e919f0
|
|
| MD5 |
fdf19ec175a05296b6d83dc5a1fe6102
|
|
| BLAKE2b-256 |
c808846dd4f44b192b7d473e8d2002b6aa680b387fe3ba640038aec2c09620bb
|