TensorPrimitives.SoftMax Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
The tensor, represented as a span.
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
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
for all elements in T
.Exp(x[i])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.