I’m trying to implement the idea of this paper for a more robust model :

  
      arxiv.org
  
  
    
1806.06108.pdf 23

375.14 KB

  
  
    
    
  
  


so the “attacker” adding more benign features will not evade the model, the core idea is that by forcing the weights to be positive only, adding benign features will not affect the output, because only features that drive the model towards positive will affect the output, pretty simple but effective.
they implemented this in keras using
tf.keras.constraints.NonNeg()

So what is the most optimal way of implementing this in a multi layer NN in pytorch? (for binary classification), meaning how should i force the weights to be 0, what activation function and optimization parameters should i use?