aesara.tensor.diag#
- aesara.tensor.diag(v, k=0)[source]#
A helper function for two ops:
ExtractDiagandAllocDiag. The namediagis meant to keep it consistent with numpy. It both accepts tensor vector and tensor matrix. While the passed tensor variablevhasv.ndim>=2, it builds aExtractDiaginstance, and returns a vector with its entries equal tov’s main diagonal; otherwise ifv.ndimis1, it builds anAllocDiaginstance, and returns a matrix withvat its k-th diaogonal.- Parameters:
v (symbolic tensor) –
k (int) – offset
- Returns:
tensor
- Return type:
symbolic tensor