Trusted-AI / adversarial-robustness-toolbox

Adversarial Robustness Toolbox (ART) - Python Library for Machine Learning Security - Evasion, Poisoning, Extraction, Inference - Red and Blue Teams

Home Page:https://adversarial-robustness-toolbox.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Troubleshooting and Solution for 'unsupported operand type(s) for /' Error in adversarial_patch_tensorflow.py (Line 277)

deepakupman opened this issue · comments

commented

Encountered the following error in the provided code snippet link. I resolved it by incorporating the provided code adjustment.

Error message:

File "C:\ProgramData\anaconda3\lib\site-packages\art\attacks\evasion\adversarial_patch\adversarial_patch_tensorflow.py", line 277, in _random_overlay
pad_h_before = int((self.image_shape[self.i_h] - image_mask.shape[self.i_h_patch + 1]) / 2)
File "C:\ProgramData\anaconda3\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 559, in truediv
raise TypeError("unsupported operand type(s) for /: 'Dimension' and '{}', "
TypeError: unsupported operand type(s) for /: 'Dimension' and 'int', please use // instead

Code fix:
pad_h_before = int((self.image_shape[self.i_h] - image_mask.shape.as_list()[self.i_h_patch + 1]) / 2)

I have implemented additional code modifications to address the same issue at line 280, 326 & 329

Please review the following changes and consider incorporating them into your repository.

Hi @deepakupman Thank you very much for noticing and reporting this issue! Would you be interested in opening a pull request for you solution?

commented

Yeah Sure, I will do it.