Numpy Version of the Code:
For Pytorch version, It seems like we cannot replace diagonal elements with a vector of elements and only a scalar value can be filled on diagonal.
Numpy Version of the Code:
For Pytorch version, It seems like we cannot replace diagonal elements with a vector of elements and only a scalar value can be filled on diagonal.
This older post provides some approaches using direct indexing to fill the diagonal with a tensor.
Thank you. It worked. I should have checked it better.