TensorPrimitives.SoftMax Method

Definition

Overloads

SoftMax(ReadOnlySpan<Single>, Span<Single>)

Computes the softmax function over the specified non-empty tensor of single-precision floating-point numbers.

SoftMax<T>(ReadOnlySpan<T>, Span<T>)

Computes the softmax function over the specified non-empty tensor of numbers.

SoftMax(ReadOnlySpan<Single>, Span<Single>)

Source:
TensorPrimitives.cs
Source:
TensorPrimitives.Single.cs
Source:
TensorPrimitives.Single.cs

Computes the softmax function over the specified non-empty tensor of single-precision floating-point numbers.

public:
 static void SoftMax(ReadOnlySpan<float> x, Span<float> destination);
public static void SoftMax (ReadOnlySpan<float> x, Span<float> destination);
static member SoftMax : ReadOnlySpan<single> * Span<single> -> unit
Public Shared Sub SoftMax (x As ReadOnlySpan(Of Single), destination As Span(Of Single))

Parameters

x
ReadOnlySpan<Single>

The tensor, represented as a span.

destination
Span<Single>

The destination tensor.

Exceptions

x and destination reference overlapping memory locations and do not begin at the same location.

Remarks

This method effectively computes a sum of MathF.Exp(x[i]) for all elements in x. It then effectively computes destination[i] = MathF.Exp(x[i]) / sum.

This method may call into the underlying C runtime or employ instructions specific to the current architecture. Exact results may differ between different operating systems or architectures.

Applies to

SoftMax<T>(ReadOnlySpan<T>, Span<T>)

Source:
TensorPrimitives.SoftMax.cs
Source:
TensorPrimitives.SoftMax.cs

Computes the softmax function over the specified non-empty tensor of numbers.

public:
generic <typename T>
 where T : System::Numerics::IExponentialFunctions<T> static void SoftMax(ReadOnlySpan<T> x, Span<T> destination);
public static void SoftMax<T> (ReadOnlySpan<T> x, Span<T> destination) where T : System.Numerics.IExponentialFunctions<T>;
static member SoftMax : ReadOnlySpan<'T (requires 'T :> System.Numerics.IExponentialFunctions<'T>)> * Span<'T (requires 'T :> System.Numerics.IExponentialFunctions<'T>)> -> unit (requires 'T :> System.Numerics.IExponentialFunctions<'T>)
Public Shared Sub SoftMax(Of T As IExponentialFunctions(Of T)) (x As ReadOnlySpan(Of T), destination As Span(Of T))

Type Parameters

T

Parameters

x
ReadOnlySpan<T>

The tensor, represented as a span.

destination
Span<T>

The destination tensor.

Exceptions

x and destination reference overlapping memory locations and do not begin at the same location.

Remarks

This method effectively computes a sum of T.Exp(x[i]) for all elements in x. It then effectively computes destination[i] = T.Exp(x[i]) / sum.

This method may call into the underlying C runtime or employ instructions specific to the current architecture. Exact results may differ between different operating systems or architectures.

Applies to