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

Add "scale_linear" preprocessing operation #155

Merged
merged 1 commit into from
Mar 26, 2021
Merged

Conversation

emilmelnikov
Copy link
Member

See #152

@@ -12,6 +12,10 @@ def make_ensure_dtype_preprocessing(dtype):
return Preprocessing(name="__tiktorch_ensure_dtype", kwargs={"dtype": dtype})


def scale_linear(tensor: xr.DataArray, *, gain, offset) -> xr.DataArray:
return gain * tensor + offset
Copy link
Collaborator

@k-dominik k-dominik Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens to overflows here? (what is supposed to happen?) Or maybe rephrase, is it okay to change dtype here?

Copy link
Member Author

@emilmelnikov emilmelnikov Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, but I think we should address this question at the spec level. That is, any decision will be easy to implement, but it needs to be consistent with the other spec implementors.

is it okay to change dtype here?

I think we have to do it anyway: gain and offset might be floats.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation casts input to a model dtype before doing any preprocessing, which is probably float32 in ~99% cases.

@m-novikov m-novikov merged commit a261fec into master Mar 26, 2021
@FynnBe FynnBe deleted the scale-linear branch June 22, 2021 09:13
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

Successfully merging this pull request may close these issues.

3 participants