In linear algebra, a linear transformation (aka linear map or linear transform) $f: \mathcal{V} \rightarrow \mathcal{W}$ is a function that satisfies the following two conditions
- $f(u + v)=f(u)+f(v)$ (additivity)
- $f(\alpha u) = \alpha f(u)$ (scalar multiplication),
where
- $u$ and $v$ vectors (i.e. elements of a vector space, which can also be $\mathbb{R}$ [proof], some space of functions, etc.)
- $\alpha$ is a scalar (e.g. which can be a real number, but not necessarily)
- $\mathcal{V}$ and $\mathcal{W}$ are vector spaces (e.g. $\mathbb{R}$ or $\mathbb{R}^2$)
So, any function that satisfies these two conditions is a linear transformation.
In Euclidean geometry, $g(x) = ax + b$ is an affine transformation, which is generally not a linear transformation as defined in linear algebra. You can easily show that affine transformations are not linear transformations. For example, let $a = 1$ and $b = 2$, does $g$ satisfy the second condition above for any scalar $\alpha$? No. For example, let $\alpha = 3$, then $g(3x = y) = y + 2 = 3x + 2 \neq 3 g(x) = 3 (x + 2) = 3x + 6$.
However, in the context of neural networks, when people use the adjective "linear" they are often referring to a line. For example, in linear regression, you can have a bias (the $b$ in the affine transformation $g$ above), which would make the function not a linear transformation, but we still call it linear regression because we fit a line (hence the name linear regression) to the data.
So, no, an affine transformation is not a linear transformation as defined in linear algebra, but all linear transformations are affine. However, in machine learning, people often use the adjective linear to refer to straight-line models, which are generally represented by functions that are affine transformations. In this answer, I also talk about this issue.