I m trying to freeze 200 random connections between the second fully connected layer(FC2  with 200 neurons ) and my third fully connected layer(FC3 , with 200 neurons) and was wondering if the following code i wrote is correct. my intention is to pick a random row then pick a random column and detach it from the computation graph.

frozen_rows = []
def remove_random_connections():    
       
    for child_number, child in enumerate(net.children()):      
   
        if child_number == 1: # second layer            
            for j in range(1000):                   
                i = random.randint(0,199) 
                k = random.randint(0,199)
                if i not in frozen_rows:
                    frozen_rows.append(i)                
                    params = list(child.parameters()) 
                    params[0].grad.data[i][k] = 0.0