Skip to content
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

There is something wrong when i run the program。 #8

Closed
sdds-torch opened this issue Dec 11, 2021 · 9 comments
Closed

There is something wrong when i run the program。 #8

sdds-torch opened this issue Dec 11, 2021 · 9 comments

Comments

@sdds-torch
Copy link

Hello,thank you very much for sharing the program.But when i run the attack.py on IncRes_V2 and Inc_v3,there is something wrong with the program.With the IncRes_V2,there is an error:ValueError: Negative dimension size caused by subtracting 5 from 3 for 'InceptionResnetV2/AuxLogits/Conv2d_2a_5x5/Conv2D' (op: 'Conv2D') with input shapes: [40,3,3,128], [5,5,128,768].And with the Inc_v3,there is an error:Tensor name "InceptionV3/AuxLogits/Conv2d_2a_3x3/BatchNorm/beta" not found in checkpoint files ./models_tf/inception_v3.ckpt
[[node save/RestoreV2 (defined at attack.py:267) ]]
Can you tell me what's wrong? Thank you very much!

@hcguoO0
Copy link
Owner

hcguoO0 commented Dec 11, 2021

Do you use InceptionResnetV2/AuxLogits/Conv2d_2a_5x5/Conv2D and InceptionV3/AuxLogits/Conv2d_2a_3x3/BatchNorm/beta as the layer_name parameter?

@sdds-torch
Copy link
Author

I used InceptionResnetV2/InceptionResnetV2/Conv2d_4a_3x3/Relu for IncRes_v2 and InceptionV3/InceptionV3/Mixed_5b/concat for Inc-v3 ,but i just used the InceptionResnetV2/AuxLogits/Conv2d_2a_5x5/Conv2D and InceptionV3/AuxLogits/Conv2d_2a_3x3/BatchNorm/beta as the layer_name parameter,it still some errors,for Inc-v3:Traceback (most recent call last):
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1864, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 748 and 20 for 'mul_1' (op: 'Mul') with input shapes: [748], [20].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "attack.py", line 329, in
tf.app.run()
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/absl/app.py", line 303, in run
_run_main(main, args)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "attack.py", line 229, in main
loss = get_fia_loss(opt_operations,weights_ph)
File "attack.py", line 110, in get_fia_loss
loss += tf.reduce_sum(adv_tensor*weights) / tf.cast(tf.size(layer), tf.float32)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 884, in binary_op_wrapper
return func(x, y, name=name)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 1180, in _mul_dispatch
return gen_math_ops.mul(x, y, name=name)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 6490, in mul
"Mul", x=x, y=y, name=name)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3616, in create_op
op_def=op_def)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2027, in init
control_input_ops)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1867, in _create_c_op
raise ValueError(str(e))
ValueError: Dimensions must be equal, but are 748 and 20 for 'mul_1' (op: 'Mul') with input shapes: [748], [20].

And for InceptionResnetV2:
File "attack.py", line 329, in
tf.app.run()
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/absl/app.py", line 303, in run
_run_main(main, args)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "attack.py", line 211, in main
logits, end_points = network_fn(x)
File "/data/sdd/biye2/FIA-main/nets/nets_factory.py", line 123, in network_fn
return func(images, num_classes, is_training=is_training,reuse=tf.AUTO_REUSE)
File "/data/sdd/biye2/FIA-main/nets/inception_resnet_v2.py", line 307, in inception_resnet_v2
padding='VALID', scope='Conv2d_2a_5x5')
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
return func(*args, **current_args)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1159, in convolution2d
conv_dims=2)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
return func(*args, **current_args)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1057, in convolution
outputs = layer.apply(inputs)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1479, in apply
return self.call(inputs, *args, **kwargs)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 537, in call
outputs = super(Layer, self).call(inputs, *args, **kwargs)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 634, in call
outputs = call_fn(inputs, *args, **kwargs)
File "/home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python/autograph/impl/api.py", line 149, in wrapper
raise e.ag_error_metadata.to_exception(type(e))
ValueError: in converted code:
relative to /home/tensor/.conda/envs/tensorflow1.9/lib/python3.6/site-packages/tensorflow/python:

keras/layers/convolutional.py:196 call
    outputs = self._convolution_op(inputs, self.kernel)
ops/nn_ops.py:1079 __call__
    return self.conv_op(inp, filter)
ops/nn_ops.py:635 __call__
    return self.call(inp, filter)
ops/nn_ops.py:234 __call__
    name=self.name)
ops/nn_ops.py:1953 conv2d
    name=name)
ops/gen_nn_ops.py:1071 conv2d
    data_format=data_format, dilations=dilations, name=name)
framework/op_def_library.py:788 _apply_op_helper
    op_def=op_def)
util/deprecation.py:507 new_func
    return func(*args, **kwargs)
framework/ops.py:3616 create_op
    op_def=op_def)
framework/ops.py:2027 __init__
    control_input_ops)
framework/ops.py:1867 _create_c_op
    raise ValueError(str(e))

ValueError: Negative dimension size caused by subtracting 5 from 3 for 'InceptionResnetV2/AuxLogits/Conv2d_2a_5x5/Conv2D' (op: 'Conv2D') with input shapes: [40,3,3,128], [5,5,128,768].

@hcguoO0
Copy link
Owner

hcguoO0 commented Dec 11, 2021

So did it occour these errors when you use InceptionResnetV2/InceptionResnetV2/Conv2d_4a_3x3/Relu for IncRes_v2 and InceptionV3/InceptionV3/Mixed_5b/concat for Inc-v3?

@sdds-torch
Copy link
Author

yes,it did.

@hcguoO0
Copy link
Owner

hcguoO0 commented Dec 11, 2021

Have you changed the code?

@sdds-torch
Copy link
Author

sdds-torch commented Dec 11, 2021 via email

@hcguoO0
Copy link
Owner

hcguoO0 commented Dec 11, 2021

I download the code and run python attack.py --model_name inception_v3 --attack_method FIA --layer_name InceptionV3/InceptionV3/Mixed_5b/concat --output_dir ./adv/fia/ --image_size 299 --ens 30 --probb 0.7

and it does not occur any errors

@sdds-torch
Copy link
Author

Okay,i tried it again,and it works.Thank you very much!

@hcguoO0 hcguoO0 closed this as completed Dec 11, 2021
@cyy280113999
Copy link

i just forget the " --image_size 299" when running the "attack.py", then the same error occured.
but i found code "utils.image_size[model_name]" in the script "verify.py", it automatically choose the size.
so why did "attack.py" still require specific "image_size"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants