-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'Patches' object has no attribute 'permute' #63
Comments
The latest version of the code is also encountering the same error for the network and VNNLIB file mentioned above.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have been experimenting with the alpha-beta-crown tool and encountered the following error while running it for some input data.
alpha-beta-crown) h@pillar1:~/project3/project3_2$ python /home/h/project2/alpha-beta-CROWN-main/complete_verifier/abcrown.py --onnx_path net.onnx --vnnlib_path prop_y0.vnnlb --device cpu --results_file 'abc_out_y0.txt' --no_incomplete
Configurations:
general:
device: cpu
seed: 100
conv_mode: patches
deterministic: false
double_fp: false
loss_reduction_func: sum
record_bounds: false
sparse_alpha: true
save_adv_example: false
precompile_jit: false
complete_verifier: bab
enable_incomplete_verification: false
csv_name: null
results_file: abc_out_y0.txt
root_path: ''
model:
name: null
path: null
onnx_path: net.onnx
onnx_path_prefix: ''
cache_onnx_conversion: false
onnx_quirks: null
input_shape: null
onnx_loader: default_onnx_and_vnnlib_loader
onnx_optimization_flags: none
data:
start: 0
end: 10000
select_instance: null
num_outputs: 10
mean: 0.0
std: 1.0
pkl_path: null
dataset: CIFAR
data_filter_path: null
data_idx_file: null
specification:
type: lp
robustness_type: verified-acc
norm: .inf
epsilon: null
vnnlib_path: prop_y0.vnnlb
vnnlib_path_prefix: ''
solver:
batch_size: 64
min_batch_size_ratio: 0.1
use_float64_in_last_iteration: false
early_stop_patience: 10
start_save_best: 0.5
bound_prop_method: alpha-crown
prune_after_crown: false
crown:
batch_size: 1000000000
max_crown_size: 1000000000
alpha-crown:
alpha: true
lr_alpha: 0.1
iteration: 100
share_slopes: false
no_joint_opt: false
lr_decay: 0.98
full_conv_alpha: true
beta-crown:
lr_alpha: 0.01
lr_beta: 0.05
lr_decay: 0.98
optimizer: adam
iteration: 50
beta: true
beta_warmup: true
enable_opt_interm_bounds: false
all_node_split_LP: false
forward:
refine: false
dynamic: false
max_dim: 10000
multi_class:
multi_class_method: allclass_domain
label_batch_size: 32
skip_with_refined_bound: true
mip:
parallel_solvers: null
solver_threads: 1
refine_neuron_timeout: 15
refine_neuron_time_percentage: 0.8
early_stop: true
adv_warmup: true
mip_solver: gurobi
bab:
initial_max_domains: 1
max_domains: .inf
decision_thresh: 0
timeout: 360
timeout_scale: 1
override_timeout: null
get_upper_bound: false
dfs_percent: 0.0
pruning_in_iteration: true
pruning_in_iteration_ratio: 0.2
sort_targets: false
batched_domain_list: true
optimized_intermediate_layers: ''
interm_transfer: true
cut:
enabled: false
bab_cut: false
lp_cut: false
method: null
lr: 0.01
lr_decay: 1.0
iteration: 100
bab_iteration: -1
early_stop_patience: -1
lr_beta: 0.02
number_cuts: 50
topk_cuts_in_filter: 100
batch_size_primal: 100
max_num: 1000000000
patches_cut: false
cplex_cuts: false
cplex_cuts_wait: 0
cplex_cuts_revpickup: true
cut_reference_bounds: true
fix_intermediate_bounds: false
branching:
method: kfsb
candidates: 3
reduceop: min
sb_coeff_thresh: 0.001
input_split:
enable: false
enhanced_bound_prop_method: alpha-crown
enhanced_branching_method: naive
enhanced_bound_patience: 100000000.0
attack_patience: 100000000.0
adv_check: 0
sort_domain_interval: -1
attack:
enabled: false
beam_candidates: 8
beam_depth: 7
max_dive_fix_ratio: 0.8
min_local_free_ratio: 0.2
mip_start_iteration: 5
mip_timeout: 30.0
adv_pool_threshold: null
refined_mip_attacker: false
refined_batch_size: null
attack:
pgd_order: before
pgd_steps: 100
pgd_restarts: 30
pgd_early_stop: true
pgd_lr_decay: 0.99
pgd_alpha: auto
pgd_loss_mode: null
enable_mip_attack: false
cex_path: ./test_cex.txt
attack_mode: PGD
gama_lambda: 10.0
gama_decay: 0.9
check_clean: false
input_split:
pgd_steps: 100
pgd_restarts: 30
pgd_alpha: auto
input_split_enhanced:
pgd_steps: 200
pgd_restarts: 5000000
pgd_alpha: auto
input_split_check_adv:
pgd_steps: 5
pgd_restarts: 5
pgd_alpha: auto
debug:
lp_test: null
Experiments at Thu Mar 14 13:23:25 2024 on pillar1
Internal results will be saved to abc_out_y0.txt.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% idx: 0, vnnlib ID: 0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Using onnx net.onnx
Using vnnlib prop_y0.vnnlb
Precompiled vnnlib file found at prop_y0.vnnlb.compiled
Loading onnx net.onnx wih quirks {}
/home/h/anaconda3/envs/alpha-beta-crown/lib/python3.7/site-packages/onnx2pytorch/convert/layer.py:30: UserWarning: The given NumPy array is not writable, and PyTorch does not support non-writable tensors. This means writing to this tensor will result in undefined behavior. You may want to copy the array to protect its data or make it writable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at /opt/conda/conda-bld/pytorch_1646755953518/work/torch/csrc/utils/tensor_numpy.cpp:178.)
layer.weight.data = torch.from_numpy(numpy_helper.to_array(weight))
/home/h/anaconda3/envs/alpha-beta-crown/lib/python3.7/site-packages/onnx2pytorch/convert/model.py:154: UserWarning: Using experimental implementation that allows 'batch_size > 1'.Batchnorm layers could potentially produce false outputs.
"Using experimental implementation that allows 'batch_size > 1'."
/home/h/anaconda3/envs/alpha-beta-crown/lib/python3.7/site-packages/torch/nn/functional.py:749: UserWarning: Note that order of the arguments: ceil_mode and return_indices will changeto match the args list in nn.MaxPool2d in a future release.
warnings.warn("Note that order of the arguments: ceil_mode and return_indices will change"
Attack parameters: initialization=uniform, steps=100, restarts=30, alpha=0.07362499833106995, initialization=uniform, GAMA=False
Model output of first 5 examples:
tensor([[-5.98954344, 2.28598309, 3.65411043]])
Adv example prediction (first 2 examples and 2 restarts):
tensor([[[-2.10495210, -0.81939900, 3.52598715]]])
PGD attack margin (first 2 examles and 10 specs):
tensor([[[1.28555310, 5.63093948]]])
number of violation: 0
Attack finished in 1.2851 seconds.
PGD attack failed
Total VNNLIB file length: 1, max property batch size: 1, total number of batches: 1
Properties batch 0, size 1
Remaining timeout: 358.6844446659088
Instance 0 first 10 spec matrices: [[[-1. 1. 0.]
[-1. 0. 1.]]]
thresholds: [0. 0.] ######
/home/h/anaconda3/envs/alpha-beta-crown/lib/python3.7/site-packages/onnx2pytorch/operations/reshape.py:36: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if (shape[0] == 1 and (len(shape) == 4 or len(shape) == 2)
/home/h/anaconda3/envs/alpha-beta-crown/lib/python3.7/site-packages/onnx2pytorch/operations/reshape.py:55: TracerWarning: Iterating over a tensor might cause the trace to be incorrect. Passing a tensor of different shape won't change the number of iterations executed (and might lead to errors or silently give incorrect results).
shape = [x if x != 0 else input.size(i) for i, x in enumerate(shape)]
Model prediction is: tensor([-5.98954344, 2.28598332, 3.65411091])
Traceback (most recent call last):
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/abcrown.py", line 650, in
main()
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/abcrown.py", line 573, in main
refined_betas=refined_betas, attack_images=all_adv_candidates, attack_margins=attack_margins)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/abcrown.py", line 404, in complete_verifier
rhs=rhs, timeout=timeout, attack_images=this_spec_attack_images)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/abcrown.py", line 209, in bab
timeout=timeout, refined_betas=refined_betas, rhs=rhs)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/batch_branch_and_bound.py", line 399, in relu_bab_parallel
domain, x, stop_criterion_func=stop_criterion(decision_thresh))
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/beta_CROWN_solver.py", line 1069, in build_the_model
(self.x,), share_slopes=share_slopes, c=self.c, bound_upper=False)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/optimized_bounds.py", line 1023, in init_slope
intermediate_layer_bounds=intermediate_layer_bounds)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/bound_general.py", line 1321, in compute_bounds
self.check_prior_bounds(final)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/bound_general.py", line 849, in check_prior_bounds
self.check_prior_bounds(n)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/bound_general.py", line 849, in check_prior_bounds
self.check_prior_bounds(n)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/bound_general.py", line 849, in check_prior_bounds
self.check_prior_bounds(n)
[Previous line repeated 9 more times]
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/bound_general.py", line 857, in check_prior_bounds
node.inputs[i], prior_checked=True)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/bound_general.py", line 959, in compute_intermediate_bounds
unstable_size=unstable_size)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/backward_bound.py", line 156, in backward_general
A, lower_b, upper_b = l.bound_backward(l.lA, l.uA, *l.inputs)
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/operators/shape.py", line 507, in bound_backward
return [(_bound_oneside(last_lA), _bound_oneside(last_uA))], 0, 0
File "/home/h/project2/alpha-beta-CROWN-main/complete_verifier/auto_LiRPA/operators/shape.py", line 505, in _bound_oneside
return last_A.permute(self.perm_inv_inc_one)
AttributeError: 'Patches' object has no attribute 'permute'
Strangely, the tool works perfectly for some other inputs.
I have attached both the neural network and VNNLB files.
net.txt
prop_y0.txt
The text was updated successfully, but these errors were encountered: