# Blog

## 5000+ Members

### MEETUPS

LEARN, CONNECT, SHARE

### JOB POSTINGS

INDEED POSTINGS

Browse through the latest deep learning, ai, machine learning postings from Indeed for the GTA.

### CONTACT

CONNECT WITH US

Are you looking to sponsor space, be a speaker, or volunteer, feel free to give us a shout.

# [N] PyTorch-NLP 0.5.0 Released! Heres to contributing back to open source, hurah! ðŸ¤—

Hi There! 🍪

2 years into PyTorch-NLP and another 6 months from the previous release, I am releasing PyTorch-NLP 0.5.0. Also, with your help, we’ll break 50,000 downloads! Thank you ðŸ™‚ I love helping the community because I myself benefit from the hard work of other open source contributors!

As always, the theme of PyTorch-NLP is to be small, extensible and intuitive much like PyTorch is! And the goal is to extend PyTorch with basic NLP utilities.

Here are the release notes highlights: 🐕

# Python 3.5 Support, Sampler Pipelining, Finer Control of Random State

• Updated my README emoji game to be more ambiguous while maintaining fun and heartwarming vibe.
• Support for Python 3.5.
• Extensive rewrite of README.md to focus on new users and building an NLP pipeline. See here.
• 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 that's more extensible and less restrictive than PyTorch's version. - Added `torchnlp.samplers.oom_batch_sampler` to sample large batches first in order to force an out-of-memory error earlier rather than later into training. - 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

randomobject = tuple([{‘t’: torch.tensor([1, 2])}, torch.tensor([2, 3])]) tensors = gettensors(random_object) assert len(tensors) == 2 “`

submitted by /u/Deepblue129