2.3.1 Scalars
Most everyday mathematics consists of manipulating numbers one at a time. Formally, we call these values scalars. For example, the temperature in Palo Alto is a balmy 72 degrees Fahrenheit. If you wanted to convert the temperature to Celsius you would evaluate the expression π =5/9(π−32), setting π to 72. In this equation, the values 5,9, and 32 are constant scalars. The variables π and π in general represent unknown scalars.
We denote scalars by ordinary lower-cased letters (e.g., π, π², and π) and the space of all (continuous) real-valued scalars by β. For expedience, we will skip past rigorous definitions of spaces: just remember that the expression π ∈ β is a formal way to say that π is a real-valued scalar. The symbol ∈ (pronounced “in”) denotes membership in a set. For example, π,π²∈{0,1} indicates that π and π² are variables that can only take values 0 or 1.
Scalars are implemented as tensors that contain only one element.
(λ₯λ¬λμμλ μ€μΉΌλΌλ₯Ό νλμ κ°μΌλ‘ νννλλ°, μ΄ κ°μ 0μ°¨μ ν μλ‘λ κ°μ£Όλλ€.(λͺ¨λ μ€μΉΌλΌλ 0μ°¨μ ν μμ΄λ€.) κ°λ¨ν μλ₯Ό λ€λ©΄, νμ΄ν μΉμμ μ€μΉΌλΌλ torch.tensor(3.14)μ κ°μ΄ ννλ μ μλλ°, μ΄λ ν¬κΈ°κ° 1μ΄κ³ κ°μ΄ 3.14μΈ ν μμ΄λ€.)
2.3.2 Vectors
For current purposes, you can think of a vector as a fixed-length array of scalars. As with their code counterparts, we call these scalars the elements of the vector (synonyms include entries and components). When vectors represent examples from real-world datasets, their values hold some real-world significance. For example, if we were training a model to predict the risk of a loan defaulting, we might associate each applicant with a vector whose components correspond to quantities like their income, length of employment, or number of previous defaults. If we were studying the risk of heart attack, each vector might represent a patient and its components might correspond to their most recent vital signs, cholesterol levels, minutes of exercise per day, etc. We denote vectors by bold lowercase letters, (e.g., π, π², and π).
Vectors are implemented as 1st-order tensors. In general, such tensors can have arbitrary lengths, subject to memory limitations. Caution: in Python, as in most programming languages, vector indices start at 0, also known as zero-based indexing, whereas in linear algebra subscripts begin at 1 (one-based indexing).
We can refer to an element of a vector by using a subscript. For example, πβ denotes the second element of π. Since πβ is a scalar, we do not bold it. By default, we visualize vectors by stacking their elements vertically.
Here πβ,…,πn are elements of the vector. Later on, we will distinguish between such column vectors and row vectors whose elements are stacked horizontally. Recall that we access a tensor’s elements via indexing.
To indicate that a vector contains π elements, we write π ∈ ββΏ. Formally, we call π the dimensionality of the vector. In code, this corresponds to the tensor’s length, accessible via Python’s built-in len function.
'Deep Learning' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[DIVE INTO DEEP LEARNING] 5.5. Generalization in Deep Learning (0) | 2023.12.29 |
---|---|
[DIVE INTO DEEP LEARNING] 2.3 Linear Algebra_matrices, tensors (1) | 2023.12.22 |
[DIVE INTO DEEP LEARNING] 4.1 Softmax Regression (0) | 2023.12.20 |
[DL] Transformer (0) | 2023.03.03 |
[DL] κ°μ±λΆμ (0) | 2023.02.21 |