Skip to main content

pytorch-tdnn

Implementation of Time Delay Neural Network (TDNN) and Factorized TDNN (TDNN-F) in PyTorch, available as layers which can be used directly.

Setup

For using (no development required)

pip install pytorch-tdnn

To install for development, clone the repository, and then run the following from within the root directory.

pip install -e .

Usage

Using the TDNN layer

from pytorch_tdnn.tdnn import TDNN as TDNNLayer

tdnn = TDNNLayer(
  512, # input dim
  512, # output dim
  [-3,0,3], # context
)

y = tdnn(x)

Here, x should have the shape (batch_size, input_dim, sequence_length).

Note: The context list should follow these constraints:

  • The length of the list should be 2 or an odd number.
  • If the length is 2, it should be of the form [-1,1] or [-3,3], but not [-1,3], for example.
  • If the length is an odd number, they should be evenly spaced with a 0 in the middle. For example, [-3,0,3] is allowed, but [-3,-1,0,1,3] is not.

Using the TDNNF layer

from pytorch_tdnn.tdnnf import TDNNF as TDNNFLayer

tdnnf = TDNNFLayer(
  512, # input dim
  512, # output dim
  256, # bottleneck dim
  1, # time stride
)

y = tdnnf(x, semi_ortho_step=True)

The argument semi_ortho_step determines whether to take the step towards semi- orthogonality for the constrained convolutional layers in the 3-stage splicing. If this call is made from within a forward() function of an nn.Module class, it can be set as follows to approximate Kaldi-style training where the step is taken once every 4 iterations:

import random
semi_ortho_step = self.training and (random.uniform(0,1) < 0.25)

Note: Time stride should be greater than or equal to 0. For example, if the time stride is 1, a context of [-1,1] is used for each stage of splicing.

Credits

This repository aims to wrap up these implementations in easy-installable PyPi packages, which can be used directly in PyTorch based neural network training.

Issues

If you find any bugs in the code, please raise an Issue, or email me at r.desh26@gmail.com.

Metadata

Release files for pytorch-tdnn 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytorch-tdnn 1.1.0
File Size Uploaded Provenance Actions
pytorch-tdnn-1.1.0.tar.gz 5.4 kB Without provenance Details for pytorch-tdnn-1.1.0.tar.gz

Release files / pytorch-tdnn-1.1.0.tar.gz

Download URL pytorch-tdnn-1.1.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2b10ae0d54bfab1ca1e3d7d133dca9d25493e905f1982eb03af58b8e2f0e2ab7
BLAKE2b-256 checksum
How to use checksums
5a52dc856464a68c6c0998086e24bd6dfe656cbe334b746118681f42f9e9a12f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.5.3

Security for pytorch-tdnn 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page