Skip to main content

Set of pytorch modules and utils to train code2seq model

Project description

code2seq

JetBrains Research Github action: build Code style: black

PyTorch's implementation of code2seq model.

Installation

You can easily install model through the PIP:

pip install code2seq

Usage

Minimal code example to run the model:

from os.path import join

import hydra
from code2seq.dataset import PathContextDataModule
from code2seq.model import Code2Seq
from code2seq.utils.vocabulary import Vocabulary
from omegaconf import DictConfig
from pytorch_lightning import Trainer


@hydra.main(config_path="configs")
def train(config: DictConfig):
    vocabulary_path = join(config.data_folder, config.dataset.name, config.vocabulary_name)
    vocabulary = Vocabulary.load_vocabulary(vocabulary_path)
    model = Code2Seq(config, vocabulary)
    data_module = PathContextDataModule(config, vocabulary)

    trainer = Trainer(max_epochs=config.hyper_parameters.n_epochs)
    trainer.fit(model, datamodule=data_module)


if __name__ == "__main__":
    train()

Navigate to code2seq/configs to see examples of configs. If you had any questions then feel free to open the issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code2seq-0.0.3.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

code2seq-0.0.3-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file code2seq-0.0.3.tar.gz.

File metadata

  • Download URL: code2seq-0.0.3.tar.gz
  • Upload date:
  • Size: 21.3 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

Hashes for code2seq-0.0.3.tar.gz
Algorithm Hash digest
SHA256 046957594f811a359eefdb95a4c1768a6b509e077175d3750fb50a635dfeeb59
MD5 ea4908451b594279722740ad20f00fb0
BLAKE2b-256 451f73c4ea02b54bcb74a399dbf5633ec0ed3fe0b3e1420993fe353447242f6e

See more details on using hashes here.

File details

Details for the file code2seq-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: code2seq-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 32.3 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

Hashes for code2seq-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9d2474a772edf20ea23b7d5242befb161453f0ac44de785e8753bcb7bca40f85
MD5 dc83f5658a987655ba7f0f747de2c931
BLAKE2b-256 0176e46e6d20767728ca30259f57244bb6658dff39c9126c95f81229cad7d713

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page