1 year ago
#346290
Clive T
How do i interleave a neural network to run half iterations on a variable then move to the next target class training?
I have a function which tries to make a neural network immune to adversarial training of the MNIST handwritten digits. I am trying to interleave the training by performing a number of adversarial training optimization iterations on the target classes 0 to 9. I want to run 200 iterations in total for each target but I want to run the first 100 iterations on each target class then move on to the next in an interleaved fashion with the same neural network then after reaching 9 it comes back to finish the remaining 100 iterations on 0 until it gets to 9. This is because if i do a full optimization on one target at a time, on the next target class the optimization does not work so i want to try to interleave the optimization and involve all target classes in one round. Right now i have a for loop which runs a function containing the neural network and it breaks to move to the next target class after 100 iterations but then the operation act in an independent way and not interleaved. How can I interleave the iteration? I am using tensorflow and the source code provided at https://github.com/Hvass-Labs/TensorFlow-Tutorials/blob/master/12_Adversarial_Noise_MNIST.ipynb
def make_immune(target_cls, num_iterations_adversary=500,
num_iterations_immune=200):
# Find the adversarial noise.
optimize(num_iterations=num_iterations_adversary,
adversary_target_cls=target_cls)
print_test_accuracy(show_example_errors=False,
show_confusion_matrix=False)
# Try and make the neural network immune to this noise.
optimize(num_iterations=num_iterations_immune)
# Newline.
# Print classification accuracy.
print_test_accuracy(show_example_errors=False,
show_confusion_matrix=False)
for i in range(2):
make_immune(target_cls=i)
if num_iteration >=100:
break
make_immune(target_cls = i+1)
if num_iteration >=100:
break
make_immune(target_cls = i+2)
else:
continue
else:
continue
# Print newline.
print()
python
tensorflow
deep-learning
mnist
generative-adversarial-network
0 Answers
Your Answer