cleverhans-lab / cleverhans

An adversarial example library for constructing attacks, building defenses, and benchmarking both
MIT License
6.15k stars 1.39k forks source link

fix CarliniWagnerL2 dtype bug #1218

Closed LPirch closed 2 years ago

LPirch commented 2 years ago

I found a bug that causes a crash when the provided x array in the CarliniWagnerL2 attack is of dtype float64. The float64 dtype is propagated to y by the util function get_or_guess_labels. Since x is casted to float32afterwards, this causes a type mismatch during optimization.

I trivially solved this by moving the cast operation upwards which does not have any other effect but prevents the above bug.