Comments (3)
Thanks for reporting the problem to us. Currently, the support of other norms is still incomplete and it works only for simple cases. I will take a look at your example to see how to fix it.
from alpha-beta-crown.
Hi everyone,
any update about l2 norm? I tried the following configuration
# This is an example configuration file that contains most useful parameter settings.
model:
name: resnet2b # This model is defined in model_defs.py. Add your own model definitions there.
path: models/cifar10_resnet/resnet2b.pth # Path to PyTorch checkpoint.
data:
dataset: CIFAR # Dataset name. This is just the standard CIFAR-10 test set defined in the "load_verification_dataset()" function in utils.py
#mean: [0.4914, 0.4822, 0.4465] # Mean for normalization.
#std: [0.2471, 0.2435, 0.2616] # Std for normalization.
start: 0 # First example to verify in dataset.
end: 100 # Last example to verify in dataset. We verify 100 examples in this test.
specification:
norm: 2
epsilon: 0.1411764705882353 # epsilon=36./255.
attack: # Currently attack is only implemented for Linf norm.
pgd_order: skip
solver:
batch_size: 2048 # Number of subdomains to compute in parallel in bound solver. Decrease if you run out of memory.
alpha-crown:
iteration: 100 # Number of iterations for alpha-CROWN optimization. Alpha-CROWN is used to compute all intermediate layer bounds before branch and bound starts.
lr_alpha: 0.1 # Learning rate for alpha in alpha-CROWN. The default (0.1) is typically ok.
beta-crown:
lr_alpha: 0.01 # Learning rate for optimizing the alpha parameters, the default (0.01) is typically ok, but you can try to tune this parameter to get better lower bound.
lr_beta: 0.05 # Learning rate for optimizing the beta parameters, the default (0.05) is typically ok, but you can try to tune this parameter to get better lower bound.
iteration: 20 # Number of iterations for beta-CROWN optimization. 20 is often sufficient, 50 or 100 can also be used.
bab:
timeout: 120 # Timeout threshold for branch and bound. Increase for verifying more points.
branching: # Parameters for branching heuristics.
reduceop: min # Reduction function for the branching heuristic scores, min or max. Using max can be better on some models.
method: kfsb # babsr is fast but less accurate; fsb is slow but most accurate; kfsb is usually a balance.
candidates: 3 # Number of candidates to consider in fsb and kfsb. More leads to slower but better branching. 3 is typically good enough.
however running the abcrown.py
script with the configuration above, I am getting the following error
Exception has occurred: RuntimeError
Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [1, 1, 3, 32, 32]
File "/home/f.brau/alpha-beta-CROWN/complete_verifier/model_defs.py", line 164, in forward
out = self.relu(self.conv1(x))
File "/home/f.brau/alpha-beta-CROWN/complete_verifier/auto_LiRPA/bound_general.py", line 110, in __init__
self.final_shape = model(
File "/home/f.brau/alpha-beta-CROWN/complete_verifier/beta_CROWN_solver.py", line 55, in __init__
self.net = BoundedModule(
File "/home/f.brau/alpha-beta-CROWN/complete_verifier/abcrown.py", line 198, in bab
self.model = LiRPANet(
File "/home/f.brau/alpha-beta-CROWN/complete_verifier/abcrown.py", line 398, in complete_verifier
l, nodes, ret = self.bab(
File "/home/f.brau/alpha-beta-CROWN/complete_verifier/abcrown.py", line 591, in main
verified_status = self.complete_verifier(
File "/home/f.brau/alpha-beta-CROWN/complete_verifier/abcrown.py", line 614, in <module>
abcrown.main()
RuntimeError: Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [1, 1, 3, 32, 32]```
Any possible easy fix?
Thanks!
from alpha-beta-crown.
@huanzhang12 could you tell us if there has been any updates on this? I am facing the exact same problem as @fabiobrau with norm = 1. Here is my configuration file GCP-CROWN/cifar_cnn_a_adv.yaml
:
model:
name: cnn_4layer_adv
path: models/sdp/cifar_cnn_a_adv.model
data:
dataset: CIFAR_SDP
start: 1
end: 5
specification:
epsilon: 0.00784313725 # 2./255.
norm: 1
attack:
pgd_restarts: 50
solver:
batch_size: 2048
beta-crown:
iteration: 20
bab:
timeout: 200
branching:
reduceop: max
cut:
enabled: True
cplex_cuts: True
bab_cut: True
lr_decay: 0.9
output:
mip_multi_proc: 20, mip_threads: 1, total threads used: 20
Process Process-2:
Traceback (most recent call last):
File "/home/yusuf/miniconda3/envs/alpha-beta-crown/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/home/yusuf/miniconda3/envs/alpha-beta-crown/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/yusuf/miniconda3/envs/alpha-beta-crown/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/lp_mip_solver.py", line 1042, in construct_mip_with_model
build_the_model_mip(model, labels_to_verify=None, save_mps=save_mps, process_dict=process_dict, x=x, intermediate_bounds=intermediate_bounds)
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/lp_mip_solver.py", line 1066, in build_the_model_mip
build_solver_model(m, timeout, mip_multi_proc=mip_multi_proc,
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/lp_mip_solver.py", line 638, in build_solver_model
out_vars = m.net.build_solver_module(
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/solver_module.py", line 50, in build_solver_module
inp_gurobi_vars = self._build_solver_input(roots[i])
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/solver_module.py", line 94, in _build_solver_input
assert node.perturbation.norm == float("inf")
AssertionError
...
...
Remaining spec index tensor([0], device='cuda:0') with bounds tensor([[-0.96139729]], device='cuda:0') need to verify.
Traceback (most recent call last):
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/abcrown.py", line 616, in <module>
abcrown.main()
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/abcrown.py", line 595, in main
verified_status = self.complete_verifier(
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/abcrown.py", line 402, in complete_verifier
l, nodes, ret = self.bab(
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/abcrown.py", line 198, in bab
self.model = LiRPANet(
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/beta_CROWN_solver.py", line 55, in __init__
self.net = BoundedModule(
File "/home/yusuf/Desktop/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/bound_general.py", line 110, in __init__
self.final_shape = model(
File "/home/yusuf/miniconda3/envs/alpha-beta-crown/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/yusuf/miniconda3/envs/alpha-beta-crown/lib/python3.9/site-packages/torch/nn/modules/container.py", line 204, in forward
input = module(input)
File "/home/yusuf/miniconda3/envs/alpha-beta-crown/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/yusuf/miniconda3/envs/alpha-beta-crown/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 463, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/home/yusuf/miniconda3/envs/alpha-beta-crown/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Expected 3D (unbatched) or 4D (batched) input to conv2d, but got input of size: [1, 1, 3, 32, 32]
Thank you.
from alpha-beta-crown.
Related Issues (20)
- need help with Regression model and batch-normalization HOT 1
- alpha-beta-crown behavior HOT 1
- alpha-beta-crown always returns timeout even for a very simple model HOT 1
- GCP-CROWN‘s SDP example error
- Unable to run BAB attack with any given configuration files
- Can I compute the upper bound using incomplete verifier? HOT 14
- RuntimeError onnx network when verifying, while network works at inference
- Documentation info and "save_adv_example" only saving last example
- Can't install HOT 9
- AssertionError on act.inputs HOT 2
- Out-Of-Memory Error / "Killed" HOT 1
- Explanation of the contents of the results file "out.txt"?
- How to run abcrown.py from inside Python? HOT 1
- It appears that there are missing indentations at line 501 and 502 in abcrown.py. HOT 1
- Inconsistency in Verification Results and Issues with Network Scaling and torch.norm Usage HOT 2
- AttributeError: 'Patches' object has no attribute 'permute' HOT 1
- "NotImplementedError: bound_dynamic_forward is not implemented for BoundMaxPool(...)" encountered while attempting to run vnncomp23's vggnet16 benchmark HOT 1
- Example using abcrown to verify visual transformer (ViT) HOT 4
- Upper bound with Beta CROWN HOT 1
- Adversarial example generation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alpha-beta-crown.