0

I am using a pretrained model that someone else has created, they have only released the model weights. Currently I am importing the model weights into my graph and calling them by the tensor names. However, this seems incompatible with cleverhans' code that seems to require a model object which has the method predict.

Is there any work around for this which does not require me to rewrite most of the cleverhans attacks because I do not have the model class and predict method?

1 Answers1

0

What you are describing should be possible but may be somewhat intensive on resources because it may recreate the graph several times. Basically, you can implement a CleverHans model class that takes in a graph checkpoint in the init method. The get_logits or fprop method should take an input tensor and load the graph to obtain the corresponding output tensor by performing some graph surgery to replace the checkpoint graph's input tensor with your own tensor: see the input_map argument in `tf.import_graph_de: https://www.tensorflow.org/api_docs/python/tf/graph_util/import_graph_def

  • Thanks for the info. Just to clarify, does the method you suggest run the risk of creating the graph multiple times? – anachronite Feb 27 '19 at 16:13
  • Yes, the graph might be created multiple times depending on how exactly you implement this approach. – Nicolas Papernot Feb 28 '19 at 17:24
  • I implemented the code as suggested. I am able to run the fast gradient method correctly but I am running into issues with projected gradient descent because of the `tf.while_loop` which goes through the `fprop` calling the `tf.train.import_meta_graph` function repeatedly. The error I get is: KeyError: "The name 'while/batch_normalization_1/cond/pred_id:0' refers to a Tensor which does not exist. The operation, 'while/batch_normalization_1/cond/pred_id', does not exist in the graph. – anachronite Feb 28 '19 at 19:50