Skip to content

Commit

Permalink
Package (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
esceptico authored Sep 26, 2021
1 parent 361559a commit db5e437
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 13 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@ Unofficial implementation of
[Perceiver IO: A General Architecture for Structured Inputs & Outputs](https://arxiv.org/abs/2107.14795)


# Installation
**From PyPI**
```shell
pip install -U perceiver-io-pytorch
```


# Usage

```python
import torch

from src.perceiver.decoders import PerceiverDecoder
from src.perceiver.encoder import PerceiverEncoder
from src.perceiver import PerceiverIO

from perceiver_io.decoders import PerceiverDecoder
from perceiver_io.encoder import PerceiverEncoder
from perceiver_io import PerceiverIO

num_latents = 128
latent_dim = 256
input_dim = 64

decoder_query_dim = 4


encoder = PerceiverEncoder(
num_latents=num_latents,
latent_dim=latent_dim,
Expand Down
4 changes: 1 addition & 3 deletions examples/language_modelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import torch
from torch import nn

from src.perceiver.decoders import PerceiverDecoder
from src.perceiver.encoder import PerceiverEncoder
from src.perceiver.perceiver import PerceiverIO
from perceiver_io import PerceiverEncoder, PerceiverDecoder, PerceiverIO


class PerceiverLM(nn.Module):
Expand Down
20 changes: 20 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from setuptools import setup


def parse_requirements(path: str = 'requirements.txt'):
with open(path) as fp:
return fp.read().strip().split()


setup(
name='perceiver-io-pytorch',
version='0.1.2',
packages=['perceiver_io'],
package_dir={'': 'src'},
url='https://github.com/esceptico/perceiver-io',
license='MIT',
author='Timur Ganiev',
author_email='ganiev.tmr@gmail.com',
description='Unofficial Perceiver IO implementation',
install_requires=parse_requirements()
)
1 change: 0 additions & 1 deletion src/perceiver/__init__.py

This file was deleted.

5 changes: 5 additions & 0 deletions src/perceiver_io/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from perceiver_io.encoder import PerceiverEncoder
from perceiver_io.decoders import (ClassificationDecoder,
PerceiverDecoder,
ProjectionDecoder)
from perceiver_io.perceiver import PerceiverIO
File renamed without changes.
2 changes: 1 addition & 1 deletion src/perceiver/decoders.py → src/perceiver_io/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
from torch import nn

from src.perceiver.attention import CrossAttention
from perceiver_io.attention import CrossAttention


class BasePerceiverDecoder(nn.Module, metaclass=ABCMeta):
Expand Down
2 changes: 1 addition & 1 deletion src/perceiver/encoder.py → src/perceiver_io/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import torch
from torch import nn

from src.perceiver.attention import CrossAttention, SelfAttention
from perceiver_io.attention import CrossAttention, SelfAttention


class PerceiverEncoder(nn.Module):
Expand Down
4 changes: 2 additions & 2 deletions src/perceiver/perceiver.py → src/perceiver_io/perceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import torch
from torch import nn

from src.perceiver.decoders import BasePerceiverDecoder
from src.perceiver.encoder import PerceiverEncoder
from perceiver_io.decoders import BasePerceiverDecoder
from perceiver_io.encoder import PerceiverEncoder


class PerceiverIO(nn.Module):
Expand Down

0 comments on commit db5e437

Please sign in to comment.