English translation
Simulated pixel values (0–255) for an image
A vector can represent either a geometric arrow or a row of features. When reading AI code, it is far more common to convert samples into feature vectors.
I verify both vector length and feature order. Even if the length is correct, an incorrect ordering still results in a fundamentally wrong meaning for the model.
Understanding the concept of vectors is essential in learning linear algebra—not merely as an abstract mathematical construct, but as a critical tool for solving real-world problems. In our previous article, we discussed the importance of linear algebra and emphasized its broad applications across modern artificial intelligence and data science. This article dives deeper into what vectors are, how they are represented, and how they appear in practical applications.
Definition of a Vector
In mathematics, a vector is a quantity possessing both magnitude and direction. It can represent points in multidimensional space, velocity, force, and other physical quantities. In linear algebra, a vector is typically expressed as an ordered list of numbers—either as a row vector or a column vector.
When learning the definition of vectors, don’t fixate solely on a sequence of numbers. First ask: What do these numbers represent? Position? Direction? Features? Weights? Clarifying this upfront makes subsequent topics—like matrices and model representations—much easier to grasp.
One-Dimensional vs. Multidimensional Vectors
Simply put, a one-dimensional vector is represented by a single number, whereas a multidimensional vector consists of multiple numbers. For example:
- One-dimensional vector:
- Two-dimensional vector:
- Three-dimensional vector:
Mathematically, denotes an -dimensional vector, where represents the set of all possible -dimensional real-valued vectors.
Representation of Vectors
Vectors can be represented in several ways; the most common include:
Before reading “Vectors and Matrices: Definition and Representation of Vectors”, first align the problem, keywords, operations, and acceptance criteria shown in the diagram. Then proceed to the main text—it’ll save effort. After reading, try re-explaining the content using your own project.
-
Coordinate Representation: In geometry, a vector is located using coordinates. For instance, a two-dimensional vector has components and , representing its projections onto the - and -axes, respectively.
-
Column Vectors and Row Vectors:
- A column vector is defined as an matrix, e.g.:
- A row vector is defined as a matrix, e.g.:
Such definitions make vectors highly compatible with matrix operations. Multiplying a row vector by a column vector yields a scalar—the dot product.
Vector Operations
Basic operations between vectors include addition and scalar multiplication.
-
Vector Addition:
Given two vectors and , their sum is: -
Scalar Multiplication:
Multiplying a scalar by a vector yields:
Example: Vectors in Machine Learning
In machine learning, feature vectors encode individual data points. For instance, in classification tasks, an image’s pixel values can be represented as a vector.
Suppose we have a grayscale image of size . Its pixels can be flattened into a one-dimensional vector. Below is a simplified version using only six pixels:
import numpy as np
# Simulated pixel values (0–255) for an image
image_pixels = np.array([255, 0, 255, 128, 64, 32]).reshape(6, 1) # Column vector
print(image_pixels)
This code produces a column vector representing the image’s pixel intensities. During model training, machine learning algorithms perform computations over such vectors to extract meaningful features.
If you haven’t fully internalized “Vectors and Matrices: Definition and Representation of Vectors”, revisit the four actions outlined on this card.
When reviewing “Vectors and Matrices: Definition and Representation of Vectors”, you need not build a full-scale project right away. Start with a simple, concrete example to confirm whether the core ideas are clear.
Summary
Vectors are a foundational concept in linear algebra, widely applied across machine learning, computer science, and many other domains. By mastering their definition and representation, we lay the groundwork for the next topic: matrices—their definition, structure, and applications. The following article will explore matrices in depth, further illuminating the architecture and utility of linear algebra.
Continue