VectorHelper
Helpers & Utilities · AiDotNet.Helpers
Provides helper methods for creating and manipulating vectors used in AI and machine learning operations.
How It Works
For Beginners: In AI and machine learning, a vector is simply a list of numbers arranged in a specific order. Think of it as a one-dimensional array or a single column/row of data. Vectors are used to represent:
- Features of a single data point (like height, weight, age of a person)
- Target values we want to predict
- Weights in a trained model
- Intermediate calculations during model training
This helper class provides convenient methods to work with vectors in your AI applications.
Methods
| Method | Summary |
|---|---|
T DotProduct(Vector<T> a, Vector<T> b) |
Computes the dot product of two vectors using hardware-accelerated operations. |
T EuclideanDistance(Vector<T> a, Vector<T> b) |
Computes the Euclidean distance between two vectors using hardware-accelerated operations. |
T L2Norm(Vector<T> vector) |
Computes the L2 (Euclidean) norm of a vector using hardware-accelerated operations. |
T ManhattanDistance(Vector<T> a, Vector<T> b) |
Computes the Manhattan (L1) distance between two vectors using hardware-accelerated operations. |
Vector<T> CreateVector(int size) |
Creates a new vector with the specified size. |
Vector<T> Normalize(Vector<T> vector, double epsilon) |
Returns a new unit-length vector in the same direction as the input. |
double CosineSimilarity(Vector<T> a, Vector<T> b, double epsilon) |
Computes the cosine similarity between two vectors, returning a value in [-1, 1]. |
void NormalizeInPlace(Vector<T> vector, double epsilon) |
Normalizes a vector in place, modifying the original vector to have unit length. |