-
Notifications
You must be signed in to change notification settings - Fork 31
/
index.html
4 lines (4 loc) · 9.19 KB
/
index.html
1
2
3
4
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Single Image · MIPVerify</title><link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css" rel="stylesheet" type="text/css"/><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="../.."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.min.js" data-main="../../assets/documenter.js"></script><script src="../../siteinfo.js"></script><script src="../../../versions.js"></script><link href="../../assets/documenter.css" rel="stylesheet" type="text/css"/></head><body><nav class="toc"><h1>MIPVerify</h1><select id="version-selector" onChange="window.location.href=this.value" style="visibility: hidden"></select><form class="search" id="search-form" action="../../search/"><input id="search-query" name="q" type="text" placeholder="Search docs"/></form><ul><li><a class="toctext" href="../../">Home</a></li><li><a class="toctext" href="../../tutorials/">Tutorials</a></li><li><span class="toctext">Finding Adversarial Examples</span><ul><li class="current"><a class="toctext" href>Single Image</a><ul class="internal"><li><a class="toctext" href="#Index-1">Index</a></li><li><a class="toctext" href="#Public-Interface-1">Public Interface</a></li></ul></li><li><a class="toctext" href="../batch_processing/">Batch Processing</a></li></ul></li><li><span class="toctext">Importing</span><ul><li><a class="toctext" href="../../utils/import_example_nets/">Example Neural Networks</a></li><li><a class="toctext" href="../../utils/import_weights/">Helpers for importing individual layers</a></li><li><a class="toctext" href="../../utils/import_datasets/">Datasets</a></li></ul></li><li><span class="toctext">Working with Neural Net Parameters</span><ul><li><a class="toctext" href="../../net_components/overview/">Overview</a></li><li><a class="toctext" href="../../net_components/layers/">Layers</a></li><li><a class="toctext" href="../../net_components/nets/">Networks</a></li><li><a class="toctext" href="../../net_components/core_ops/">Core Operations</a></li></ul></li></ul></nav><article id="docs"><header><nav><ul><li>Finding Adversarial Examples</li><li><a href>Single Image</a></li></ul><a class="edit-page" href="https://github.com/vtjeng/MIPVerify.jl/blob/master/docs/src/finding_adversarial_examples/single_image.md"><span class="fa"></span> Edit on GitHub</a></nav><hr/><div id="topbar"><span>Single Image</span><a class="fa fa-bars" href="#"></a></div></header><h1><a class="nav-anchor" id="Single-Image-1" href="#Single-Image-1">Single Image</a></h1><p><a href="#MIPVerify.find_adversarial_example-Tuple{NeuralNet,Array{#s165,N} where N where #s165<:Real,Union{Integer, Array{#s164,1} where #s164<:Integer},Any,Dict}"><code>find_adversarial_example</code></a> finds the closest adversarial example to a given input image for a particular <a href="../../net_components/overview/#MIPVerify.NeuralNet"><code>NeuralNet</code></a>.</p><p>As a sanity check, we suggest that you verify that the <a href="../../net_components/overview/#MIPVerify.NeuralNet"><code>NeuralNet</code></a> imported achieves the expected performance on the test set. This can be done using <a href="#MIPVerify.frac_correct-Tuple{NeuralNet,MIPVerify.LabelledDataset,Integer}"><code>frac_correct</code></a>.</p><h2><a class="nav-anchor" id="Index-1" href="#Index-1">Index</a></h2><ul></ul><h2><a class="nav-anchor" id="Public-Interface-1" href="#Public-Interface-1">Public Interface</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="MIPVerify.find_adversarial_example-Tuple{NeuralNet,Array{#s165,N} where N where #s165<:Real,Union{Integer, Array{#s164,1} where #s164<:Integer},Any,Dict}" href="#MIPVerify.find_adversarial_example-Tuple{NeuralNet,Array{#s165,N} where N where #s165<:Real,Union{Integer, Array{#s164,1} where #s164<:Integer},Any,Dict}"><code>MIPVerify.find_adversarial_example</code></a> — <span class="docstring-category">Method</span>.</div><div><div><pre><code class="language-julia">find_adversarial_example(nn, input, target_selection, optimizer, main_solve_options; invert_target_selection, pp, norm_order, adversarial_example_objective, tightening_algorithm, tightening_options, solve_if_predicted_in_targeted)
</code></pre><p>Finds the perturbed image closest to <code>input</code> such that the network described by <code>nn</code> classifies the perturbed image in one of the categories identified by the indexes in <code>target_selection</code>.</p><p><code>optimizer</code> specifies the optimizer used to solve the MIP problem once it has been built.</p><p>The output dictionary has keys <code>:Model, :PerturbationFamily, :TargetIndexes, :SolveStatus, :Perturbation, :PerturbedInput, :Output</code>. See the <a href="https://nbviewer.jupyter.org/github/vtjeng/MIPVerify.jl/blob/master/examples/03_interpreting_the_output_of_find_adversarial_example.ipynb">tutorial</a> on what individual dictionary entries correspond to.</p><p><em>Formal Definition</em>: If there are a total of <code>n</code> categories, the (perturbed) output vector <code>y=d[:Output]=d[:PerturbedInput] |> nn</code> has length <code>n</code>. We guarantee that <code>y[j] - y[i] ≥ 0</code> for some <code>j ∈ target_selection</code> and for all <code>i ∉ target_selection</code>.</p><p><strong>Named Arguments:</strong></p><ul><li><code>invert_target_selection::Bool</code>: Defaults to <code>false</code>. If <code>true</code>, sets <code>target_selection</code> to be its complement.</li><li><code>pp::PerturbationFamily</code>: Defaults to <code>UnrestrictedPerturbationFamily()</code>. Determines the family of perturbations over which we are searching for adversarial examples.</li><li><code>norm_order::Real</code>: Defaults to <code>1</code>. Determines the distance norm used to determine the distance from the perturbed image to the original. Supported options are <code>1</code>, <code>Inf</code> and <code>2</code> (if the <code>optimizer</code> used can solve MIQPs.)</li><li><code>tightening_algorithm::MIPVerify.TighteningAlgorithm</code>: Defaults to <code>mip</code>. Determines how we determine the upper and lower bounds on input to each nonlinear unit. Allowed options are <code>interval_arithmetic</code>, <code>lp</code>, <code>mip</code>. (1) <code>interval_arithmetic</code> looks at the bounds on the output to the previous layer. (2) <code>lp</code> solves an <code>lp</code> corresponding to the <code>mip</code> formulation, but with any integer constraints relaxed. (3) <code>mip</code> solves the full <code>mip</code> formulation.</li><li><code>tightening_options</code>: Solver-specific options passed to optimizer when used to determine upper and lower bounds for input to nonlinear units. Note that these are only used if the <code>tightening_algorithm</code> is <code>lp</code> or <code>mip</code> (no solver is used when <code>interval_arithmetic</code> is used to compute the bounds). Defaults for Gurobi and Cbc to a time limit of 20s per solve, with output suppressed.</li><li><code>solve_if_predicted_in_targeted</code>: Defaults to <code>true</code>. The prediction that <code>nn</code> makes for the unperturbed <code>input</code> can be determined efficiently. If the predicted index is one of the indexes in <code>target_selection</code>, we can skip the relatively costly process of building the model for the MIP problem since we already have an "adversarial example" –- namely, the input itself. We continue build the model and solve the (trivial) MIP problem if and only if <code>solve_if_predicted_in_targeted</code> is <code>true</code>.</li></ul></div></div></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="MIPVerify.frac_correct-Tuple{NeuralNet,MIPVerify.LabelledDataset,Integer}" href="#MIPVerify.frac_correct-Tuple{NeuralNet,MIPVerify.LabelledDataset,Integer}"><code>MIPVerify.frac_correct</code></a> — <span class="docstring-category">Method</span>.</div><div><div><pre><code class="language-julia">frac_correct(nn, dataset, num_samples)
</code></pre><p>Returns the fraction of items the neural network correctly classifies of the first <code>num_samples</code> of the provided <code>dataset</code>. If there are fewer than <code>num_samples</code> items, we use all of the available samples.</p><p><strong>Named Arguments:</strong></p><ul><li><code>nn::NeuralNet</code>: The parameters of the neural network.</li><li><code>dataset::LabelledDataset</code>:</li><li><code>num_samples::Integer</code>: Number of samples to use.</li></ul></div></div></section><footer><hr/><a class="previous" href="../../tutorials/"><span class="direction">Previous</span><span class="title">Tutorials</span></a><a class="next" href="../batch_processing/"><span class="direction">Next</span><span class="title">Batch Processing</span></a></footer></article></body></html>