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

[Accessibility] Add option to reduce precision when printing tensors to screen #1285

Closed
a-alhusaini opened this issue Aug 26, 2023 · 3 comments

Comments

@a-alhusaini
Copy link

It would make Nx a lot more accessible for screen readers if I could limit the precision of the output when printing tensors to screen.

I didn't know that the numbers Nx was printing to the screen were in scientific notation because I was skipping some of the digits with my screen reader (there is just too many of them)

This happenned here: elixir-nx/axon#526

I propose we add a config option that limits precision when tensors are printed ot the screen. Instead of a tensor that looks like this:

#Nx.Tensor<
  f32[1][10]
  EXLA.Backend<host:0, 0.3007448411.1655570452.243887>
  [
    [2.3431260944184697e-23, 4.296128036651581e-11, 1.0659236316176752e-17, 0.9999992847442627, 6.712944780263512e-22, 1.0, 2.8145804840526482e-22, 2.4531429665408666e-10, 9.463095196338145e-9, 2.6594868813845096e-6]
  ]
>

We would have

#Nx.Tensor<
  f32[1][10]
  EXLA.Backend<host:0, 0.3007448411.1655570452.243887>
  [
    [2.97e-23, 4.81e-11, 1.52e-17, 0.9927, 6.12e-22, 1.0, 2.82e-22, 2.66e-10, 9.45e-9, 2.46e-6]
  ]
>

This shortened format would make Nx a lot easier to interact with for blind users (like me)

@josevalim
Copy link
Collaborator

Hi @a-alhusaini! We should definitely do something because the precision we print is also misleading, f32 doesn't have such a large precision, and maybe fixing that will already improve this issue considerably. See #448.

@a-alhusaini
Copy link
Author

a-alhusaini commented Aug 26, 2023

the precision we print is also misleading,

I'm surprised I only noticed this when you pointed it out. This leads me to conclude that most Nx users don't really care about the exact numbers being printed to the screen. Maybe truncating the printed output should be a default instead of a configuration option?

Just an idea I had. Not sure if it is good or not.

@josevalim
Copy link
Collaborator

The precision it prints has additional digits which we should discard. Maybe nobody cares about the additional digits but they may care about missing digits.

I don't know either, just adding more context. :)

@polvalente polvalente changed the title [Accessability] Add option to reduce precision when printing tensors to screen [Accessibility] Add option to reduce precision when printing tensors to screen Aug 26, 2023
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

No branches or pull requests

2 participants