Class InputHelper<T, TInput>
Provides helper methods for input-related operations.
public static class InputHelper<T, TInput>
Type Parameters
TTInput
- Inheritance
-
InputHelper<T, TInput>
- Inherited Members
Methods
CreateSingleItemBatch(TInput)
Creates a batch containing a single item.
public static TInput CreateSingleItemBatch(TInput item)
Parameters
itemTInputThe single item to include in the batch.
Returns
- TInput
A batch containing only the provided item.
Exceptions
- ArgumentNullException
Thrown when the item is null.
- InvalidOperationException
Thrown when a type conversion fails.
- NotSupportedException
Thrown when the item type is not supported.
GetBatch(TInput, int[])
Extracts a batch of data from the input based on the specified indices.
public static TInput GetBatch(TInput input, int[] indices)
Parameters
inputTInputThe input data structure.
indicesint[]The indices of the elements or rows to include in the batch.
Returns
- TInput
A new data structure containing only the selected elements.
Exceptions
- ArgumentNullException
Thrown when the input or indices are null.
- ArgumentException
Thrown when the input type is not supported or indices are invalid.
GetBatchSize(TInput)
Gets the batch size from the input data.
public static int GetBatchSize(TInput input)
Parameters
inputTInputThe input data.
Returns
- int
The batch size of the input data.
GetElement(TInput, int, int)
Gets an element at the specified position from the input data structure.
public static T GetElement(TInput input, int row, int column)
Parameters
Returns
- T
The element at the specified position.
Remarks
This method extracts a specific element from the input data structure based on row and column indices. It supports Matrix<T>, Vector<T>, and Tensor<T> input types.
For Beginners: This method helps you access specific values from your data. Think of it like looking up a value in a spreadsheet by providing the row and column numbers.
Exceptions
- ArgumentNullException
Thrown when the input is null.
- ArgumentException
Thrown when the input type is not supported.
- ArgumentOutOfRangeException
Thrown when the indices are out of range.
GetFeatureValue(TInput, int)
Retrieves a specific feature value from an input item.
public static T GetFeatureValue(TInput input, int featureIndex)
Parameters
inputTInputThe input item.
featureIndexintThe index of the feature to retrieve.
Returns
- T
The value of the specified feature.
Remarks
For Beginners: This method extracts one specific value from your data. If your data represents features of something (like height, weight, color of an object), this method lets you get just one of those features.
Exceptions
- ArgumentNullException
Thrown when input is null.
- ArgumentOutOfRangeException
Thrown when featureIndex is negative or exceeds feature count.
- NotSupportedException
Thrown when the input type is not supported.
GetInputSize(TInput)
Gets the size of the input data.
public static int GetInputSize(TInput input)
Parameters
inputTInputThe input data.
Returns
- int
The size of the input data.
GetItem(TInput, int)
Retrieves a single item from a batch of input data.
public static TInput GetItem(TInput input, int index)
Parameters
inputTInputThe batch of input data.
indexintThe index of the item to retrieve.
Returns
- TInput
A single item from the batch at the specified index.
Remarks
For Beginners: This method extracts a single example from your data. Think of it like selecting one row from a spreadsheet of many rows.
Exceptions
- ArgumentNullException
Thrown when input is null.
- ArgumentOutOfRangeException
Thrown when index is negative or exceeds input dimensions.
- NotSupportedException
Thrown when the input type is not supported.