Download Latest Version Python 3.5 Support, Sampler Pipelining, Finer Control of Random State, New Corporate Sponsor source code.zip (861.1 kB)
Email in envelope

Get an email when there's a new version of PyTorch Natural Language Processing

Home / 0.5.0
Name Modified Size InfoDownloads / Week
Parent folder
Python 3.5 Support, Sampler Pipelining, Finer Control of Random State, New Corporate Sponsor source code.tar.gz 2019-11-04 790.1 kB
Python 3.5 Support, Sampler Pipelining, Finer Control of Random State, New Corporate Sponsor source code.zip 2019-11-04 861.1 kB
README.md 2019-11-04 4.5 kB
Totals: 3 Items   1.7 MB 0

Major Updates

  • Updated my README emoji game to be more ambiguous while maintaining fun and heartwarming vibe. 🐕
  • Support for Python 3.5
  • Extensive rewrite of README to focus on new users and building an NLP pipeline.
  • Support for Pytorch 1.2
  • Added torchnlp.random for finer grain control of random state building on PyTorch's fork_rng. This module controls the random state of torch, numpy and random.

    :::python import random import numpy import torch

    from torchnlp.random import fork_rng

    with fork_rng(seed=123): # Ensure determinism print('Random:', random.randint(1, 231)) print('Numpy:', numpy.random.randint(1, 231)) print('Torch:', int(torch.randint(1, 2**31, (1,)))) - Refactored torchnlp.samplers enabling pipelining. For example:

    :::python from torchnlp.samplers import DeterministicSampler from torchnlp.samplers import BalancedSampler

    data = ['a', 'b', 'c'] + ['c'] * 100 sampler = BalancedSampler(data, num_samples=3) sampler = DeterministicSampler(sampler, random_seed=12) print([data[i] for i in sampler]) # ['c', 'b', 'a'] - Added torchnlp.samplers.balanced_sampler for balanced sampling extending Pytorch's WeightedRandomSampler. - Added torchnlp.samplers.deterministic_sampler for deterministic sampling based on torchnlp.random. - Added torchnlp.samplers.distributed_batch_sampler for distributed batch sampling. - Added torchnlp.samplers.oom_batch_sampler to sample large batches first in order to force an out-of-memory error. - Added torchnlp.utils.lengths_to_mask to help create masks from a batch of sequences. - Added torchnlp.utils.get_total_parameters to measure the number of parameters in a model. - Added torchnlp.utils.get_tensors to measure the size of an object in number of tensor elements. This is useful for dynamic batch sizing and for torchnlp.samplers.oom_batch_sampler.

    :::python from torchnlp.utils import get_tensors

    random_object_ = tuple([{'t': torch.tensor([1, 2])}, torch.tensor([2, 3])]) tensors = get_tensors(random_object_) assert len(tensors) == 2 - Added a corporate sponsor to the library: https://wellsaidlabs.com/

Minor Updates

Source: README.md, updated 2019-11-04