Introducing Adversarial Training in TensorFlow

I would like to implement the following cost function for my neural network: gif.latex?%5Cwidetilde&space;J(%5Ctheta,x,t)&space;=&space;J(%5Ctheta,x,t)&space;+&space;J(%5Ctheta,x+%5Cepsilon&space;%5Cnabla&space;J(%5Ctheta,&space;x,&space;t))

It uses contention inputs for the neural network to improve generalization [ref] .

In particular, I am having problems with gif.latex?x+%5Cepsilon%5Cnabla&space;J(%5Ctheta,&space;x,&space;t) part. On my TensorFlow chart, I defined gif.latex?J(%5Ctheta,&space;x,&space;t) like an operation. How can i pass gif.latex?J argument other than gif.latex?x ?

The only way I've found so far for this is to define a parallel network gif.latex?J%27(%5Ctheta,&space;x&space;+&space;%5CDelta,&space;t) that shares the weights with my source network and passes it gif.latex?x&space;+&space;%5CDelta into your feed_dict argument. If possible, I would like to avoid overriding my entire network. How can i do this?


My TensorFlow model is written as:

 x = tf.placeholder(tf.float32, [None, 32, 32]); ... # A simple neural network y = tf.add(tf.matmul(h, W1), b1); cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(y, t)); 

Perhaps relevant:

tf.stop_gradient (input, name = None)

Stop gradient calculation.

... much more ...

  • Individual preparation in which backprop should not occur through the process of creating a competitive example.

https://www.tensorflow.org/versions/r0.7/api_docs/python/train.html#stop_gradient

+5
source share
1 answer

You need to write your model in such a way that it supports challenges such as

 output = model.fprop(input_tensor) 

or

 output = model.fprop(input_tensor, params) 

The fprop method twice generates the same direct distribution expression, but with a different input tensor for each call:

 raw_output = model.fprop(clean_examples) adv_examples = ... adv_output = model.fprop(adv_examples) 

If you want to apply this to one of our open source models and do not support the interface for this, write about the problem on github.

+5
source

Source: https://habr.com/ru/post/1246006/


All Articles