Suppose I have a scalar function $L(W)$ $L:\mathbb{R}^{n \times n} \rightarrow \mathbb{R}$.
I would like to know the directional derivative $\frac{dL}{dW}$ with respect to some vector $v$.
Background: $L$ is the loss of a neural network parametrized by $W$, e.g. the entries $w_{ij}$ are the connection weights of, say, a vanilla RNN. At initialisation $w_{ij}$ ~ $\mathcal{N}_{(0,1)}$, so the eigenvalues are uniformly distributed on the unit disk. Now, suppose I train the network for a duration $t$. This introduces some perturbation $\Delta W=W_t-W_0$, causing some eigenvalues to separate from the bulk. Say, I have $k$ such outliers $\lambda_1, \ldots, \lambda_k$, associated with eigenvectors $v_1, \ldots, v_k$. Now, during the forward pass, the dynamics unfolds in a subspace spanned by the $v_i$, as all other eigenvalues have modulus below unity. What I would like to measure is basically how much of the gradient at some later time $t'$, $\frac{dL}{dW_t'}$ is contained in the subspace spanned by the $v_i$, i.e. I want some scalar output, which I guess is somewhat analogous to the directional derivative of some vector-valued $f(x)$ function which tells you how much the $f$ slopes in the direction of some vector $v$. In effect this measures the correlation between the gradient of $f$ and $v$. So basically I would like to do something similar only for a function defined over matrices, if that even makes sense.
Perhaps there is something really obvious that I am missing. If not I'll be happy to elaborate and show some of my ansatzes.