TensorPlay

Latest development documentation · Updated 2026-09-08. A documentation snapshot for package 1.0.0.dev20260909 is not available.

On this page

Functions 15

#

calculate_gain

functionFull reference ↗
tensorplay.nn.init.calculate_gain(nonlinearity, param=None)[source]

Return the recommended gain value for the given nonlinearity.

Supported names: linear/conv{1,2,3}d/conv_transpose{1,2,3}d and sigmoid map to 1, tanh to 5/3, relu to sqrt(2), selu to 3/4, and leaky_relu to sqrt(2 / (1 + negative_slope**2)) where the slope is taken from param (default 0.01).

#

dirac_

functionFull reference ↗
tensorplay.nn.init.dirac_(tensor, groups=1)[source]

Fill the {3, 4, 5}-D tensor in-place with Dirac delta kernels.

Preserves identity of inputs in convolutional layers; with groups > 1 each group of output channels preserves identity independently.

#

eye_

functionFull reference ↗
tensorplay.nn.init.eye_(tensor)[source]

Fill the 2-D tensor in-place with the identity matrix.

As many inputs as possible are preserved through a Linear layer.

#

kaiming_normal_

functionFull reference ↗
tensorplay.nn.init.kaiming_normal_(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu', generator=None)[source]

Fill tensor in-place with N(0, std^2) where std = gain / sqrt(fan).

#

kaiming_uniform_

functionFull reference ↗
tensorplay.nn.init.kaiming_uniform_(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu', generator=None)[source]

Fill tensor in-place with U(-bound, bound) where bound = gain * sqrt(3 / fan).

#

normal_

functionFull reference ↗
tensorplay.nn.init.normal_(tensor, mean=0.0, std=1.0, generator=None)[source]

Fill tensor in-place with samples from N(mean, std^2).

#

orthogonal_

functionFull reference ↗
tensorplay.nn.init.orthogonal_(tensor, gain=1, generator=None)[source]

Fill tensor in-place with a (semi) orthogonal matrix.

The tensor must have at least 2 dimensions; trailing dimensions are flattened. Rows (or columns, when narrower) are orthonormalized with a QR factorization of a standard-normal sample, and Q is rescaled by the diagonal signs of R so its distribution is uniform over the orthogonal group.

#

sparse_

functionFull reference ↗
tensorplay.nn.init.sparse_(tensor, sparsity, std=0.01, generator=None)[source]

Fill the 2-D tensor in-place as a sparse matrix.

Each column gets sparsity * rows zeroed entries (a random row subset per column); the remaining entries come from N(0, std^2).

#

uniform_

functionFull reference ↗
tensorplay.nn.init.uniform_(tensor, a=0.0, b=1.0, generator=None)[source]

Fill tensor in-place with samples from U(a, b).

#

xavier_normal_

functionFull reference ↗
tensorplay.nn.init.xavier_normal_(tensor, gain=1.0, generator=None)[source]

Fill tensor in-place with N(0, std^2) where std = gain * sqrt(2 / (fan_in + fan_out)).

#

xavier_uniform_

functionFull reference ↗
tensorplay.nn.init.xavier_uniform_(tensor, gain=1.0, generator=None)[source]

Fill tensor in-place with U(-a, a) where a = gain * sqrt(6 / (fan_in + fan_out)).

Search documentation

Search all 1,743 documentation pages.

Keyboard shortcuts

Global

  • /Focus search
  • ?This dialog
  • ,Open settings
  • jAI assistant

Search

  • Navigate results
  • Open result
  • escClose

Package

  • mMain information
  • dDocs
  • .Code
  • -Changelog
  • tTimeline
  • sStats
  • vVersions