as791 / ZOO_Attack_PyTorch

This repository contains the PyTorch implementation of Zeroth Order Optimization Based Adversarial Black Box Attack (https://arxiv.org/abs/1708.03999)
MIT License
35 stars 13 forks source link

Use eval mode during validation #7

Open wutongshenqiu opened 2 years ago

wutongshenqiu commented 2 years ago

Hi, thanks for the useful project written in pytorch. When looking into the code, I found that some places could be optimized:

  1. Use model.eval() during validation. According to the documentation of pytorch, Dropout behaves differently between 'train' and 'eval' mode. And both models used in cifar10 and mnist have Dropout layers.
  2. Wrapping validation part with with torch.no_grad() may save time and memory.
as791 commented 2 years ago

Hi I will check this @wutongshenqiu . Thank you for this info.