Training of multi-label embeddings for k-shingled input sequences
Project description
torch-multilabel-embedding : Training of multi-label embeddings with k-shingled input sequences
k-shingled input sequences are multi-dimensional, i.e. the input embedding must process multi-label inputs instead of one-hot encoded inputs.
Usage
import torch_multilabel_embedding as tml
import torch
# a sequence of multi-label data points
x_ids = [[1, 2, 4], [0, 1, 2], [2, 1, 4], [3, 2, 1]]
x_ids = torch.tensor(x_ids)
# initialize layer
layer = tml.MultiLabelEmbedding(
vocab_size=5, embed_size=300, random_state=42)
# predict
y = layer(x_ids)
Appendix
Installation
The torch-multilabel-embedding git repo is available as PyPi package
pip install torch-multilabel-embedding
pip install git+ssh://git@github.com/ulf1/torch-multilabel-embedding.git
Install a virtual environment
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt --no-cache-dir
pip install -r requirements-dev.txt --no-cache-dir
pip install -r requirements-demo.txt --no-cache-dir
(If your git repo is stored in a folder with whitespaces, then don’t use the subfolder .venv. Use an absolute path without whitespaces.)
Python commands
Jupyter for the examples: jupyter lab
Check syntax: flake8 --ignore=F401 --exclude=$(grep -v '^#' .gitignore | xargs | sed -e 's/ /,/g')
Run Unit Tests: PYTHONPATH=. pytest
Publish
pandoc README.md --from markdown --to rst -s -o README.rst
python setup.py sdist
twine upload -r pypi dist/*
Clean up
find . -type f -name "*.pyc" | xargs rm
find . -type d -name "__pycache__" | xargs rm -r
rm -r .pytest_cache
rm -r .venv
Support
Please open an issue for support.
Contributing
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.
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
Hashes for torch-multilabel-embedding-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ca74d0c036671236a7f8d2585bcb2d1f26a6d8694381ec448138c0e3e49a8eb |
|
MD5 | 6cda34bf5d9b0bd4b4608f9b9c10ce18 |
|
BLAKE2b-256 | 9663c2091a2d9dea3683a9230f70b7fa092da79ed17959ce3c951b779ee56f7f |