Click or drag to resize
Accord.NET (logo)

VectorOneHotT Method (Int32, Int32)

Creates a one-hot vector, where all values are zero except for the indicated index, which is set to one.

Namespace:  Accord.Math
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax
public static T[] OneHot<T>(
	int index,
	int columns
)
Request Example View Source

Parameters

index
Type: SystemInt32
The vector's dimension which will be marked as one.
columns
Type: SystemInt32
The size (length) of the vector.

Type Parameters

T
The data type for the vector.

Return Value

Type: T
A one-hot vector where only a single position is one and the others are zero.
See Also