I added the following function to my model architecture to reshape my parameter vector L_vec
inside the model to a triangular shape matrix. However I need to map manually the device of matrix to the device of L_vec.
I am not sure what could be the reason.
def train_tensor(self, L_vec, n):
tri_mat = torch.zeros((n, n)).to(L_vec.device)
tril_indices = torch.tril_indices(row=n, col=n, offset=0)
tri_mat[tril_indices[0], tril_indices[1]] = L_vec.squeeze(1)
return tri_mat