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 argparse import ArgumentParser

from omegaconf import DictConfig, OmegaConf
from pytorch_lightning import Trainer

from code2seq.data.path_context_data_module import PathContextDataModule
from code2seq.model import Code2Seq


def train(config: DictConfig):
    # Load data module
    data_module = PathContextDataModule(config.data_folder, config.data)
    data_module.prepare_data()
    data_module.setup()

    # Load model
    model = Code2Seq(
        config.model,
        config.optimizer,
        data_module.vocabulary,
        config.train.teacher_forcing
    )

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


if __name__ == "__main__":
    __arg_parser = ArgumentParser()
    __arg_parser.add_argument("config", help="Path to YAML configuration file", type=str)
    __args = __arg_parser.parse_args()

    __config = OmegaConf.load(__args.config)
    train(__config)

Navigate to config directory to see examples of configs. If you have 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-1.0.3.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

code2seq-1.0.3-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: code2seq-1.0.3.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for code2seq-1.0.3.tar.gz
Algorithm Hash digest
SHA256 f4d4b789db058cc0feb10a2435c38e602b2f3eff0874d9e27beb20d78416f8e3
MD5 a708afd02948263efafd36537502d4f6
BLAKE2b-256 e7980c994ffbacf92ccc6d2d4defa17335fd50689ac76fcd6953abc98257e762

See more details on using hashes here.

File details

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

File metadata

  • Download URL: code2seq-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for code2seq-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d34ddfb339a58d7a7adebbe9cca062bdc71add3af1f001a0d67886fdd05cb1bf
MD5 1a3c67692835a794c469372b25b897fa
BLAKE2b-256 2e4d8eeeab69abc992f3663485455c57ffca5a4785c5046d5bb17420d83dd29c

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