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

insert_image in art.attacks.poisoning.perturbations does not preserve the dtype of the passed ndarray. #1440

Closed
keykholt opened this issue Dec 13, 2021 · 1 comment · Fixed by #1441
Assignees
Labels
bug Something isn't working
Milestone

Comments

@keykholt
Copy link
Collaborator

Describe the bug
When passing data to insert_image, the returned type of the array is not the same as the original data passed. This can occasionally cause issues with data types when using the returned value. This is probably a minor issue and I can bypass this issue by simply converting the returned data back to the original dtype, but it might be nice to not require this step.

To Reproduce
In my case, I had a PyTorch model trained using input data with dtype=float32. The pytorch model weights appeared to be float tensors.
Steps:

  1. I feed the input data of dtype=float32 to insert_image and receive a numpy array with dtype=float64
  2. I convert the returned value into a PyTorch Tensor using torch.from_numpy(). This converts the returned value into a DoubleTensor
  3. An error occurs when I use the converted tensor as input to art.estimator.get_activations(). The error is RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same

I get similar issues if I pass an Int. I will get a float back.

Expected behavior
The dtype of the input to insert_image should be preserved.

System information (please complete the following information):

  • Unbuntu 18.04
  • Python 3.8
  • ART 1.9
@beat-buesser beat-buesser added the bug Something isn't working label Dec 13, 2021
@beat-buesser beat-buesser added this to the ART 1.9.0 milestone Dec 13, 2021
@beat-buesser
Copy link
Collaborator

Hi @keykholt Thank you very much for reporting this issue!

@beat-buesser beat-buesser linked a pull request Dec 14, 2021 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants