I am trying to make a vector based on the conditions of a matrix that already exists. Essentially, I am trying to find if the sum of a row is = to 0 and if it is I want to make a new vector where that row is now 1. And if the row is = to 1 I want that new vector to have that row as 0. (This vector has only 1, row and 1 column). So far I have started to make a new vector with all 0s. Then I created an if statement, but I was not sure how to reference that the row has to match with the matrix row that was tested. I made the if statemet but i am not sure it is working properly
Here is my code:
a_mat=torch.zeros(n,1)
if torch.sum(self.P, dim= 0) == 0:
a_mat[i]= 1
if torch.sum(self.P, dim= 0) == 1:
a_mat[i]= 0