Hi James!



 6fb4b64ff0a68bcbf8fa:

my source
        s_f,v_f=torch.eig(features[i], eigenvectors=True)

but
loss.backward()
in this source, error like this
the derivative for ‘eig’ is not implemented
i don’t know why this error occured.


Gradients (“backward pass”) are not implemented for
torch.eig().  If your features matrix is symmetric
(or can naturally be made symmetric), you can use
torch.symeig(), otherwise you will have to rethink
your loss function.
From the documentation for torch.eig() 7:
Since eigenvalues and eigenvectors might be
complex, backward pass is supported only for
torch.symeig()

Also note, from torch.symeig() 27:
Extra care needs to be taken when backward through
outputs. Such operation is really only stable when
all eigenvalues are distinct. Otherwise, NaN can
appear as the gradients are not properly defined.

Let me just say that there is nothing fundamentally improper
about using eigenvalues (or eigenvectors) as ingredients in
your loss function, but eigenvalues can be a little tricky, both
in terms of how they depend mathematically on your inputs,
and sometimes the numerical stability of the algorithms used
to calculate them.  So you should think through carefully how
and why you’re using them.
Cheers!
K. Frank