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

enable explicit dtype cast in alibi detect server #3940

Closed
RafalSkolasinski opened this issue Feb 17, 2022 · 0 comments · Fixed by #3958
Closed

enable explicit dtype cast in alibi detect server #3940

RafalSkolasinski opened this issue Feb 17, 2022 · 0 comments · Fixed by #3958
Labels

Comments

@RafalSkolasinski
Copy link
Contributor

This issue is on behaviour currently present in Alibi Detect Server.

Alibi Detect library expects float input to be float32 type in most cases when numerical data is expected.
Currently in alibi-detect-server, e.g. here


we cast input to np.array without specifying the dtype. This is bad as the default will be float64

>>> np.array([1.1, 2.2, 3.3]).dtype
dtype('float64')

Some detectors will ignore it but some that relies strongly on Tensorflow will unfortunately fail.

For SC 1.13 that uses AD 0.8.1 this can be worked-around by adding a dummy preprocessing in detector artifact:

preprocess_fn = lambda x: x.astype(np.float32)
dd = DetectorClassHere(x_ref=..., preprocess_fn = preprocess_fn, ...)

but this solution is not ideal.

One idea that comes to my mind would be on the server side to do following casting:

  • if dtype is float64 -> cast to float32
  • if dtype is int64 -> cast to int32
  • else: do not do anything

Environment

SC up to 1.13.0

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

Successfully merging a pull request may close this issue.

1 participant