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

Make line wrapping and precision of tf.print configurable. #52960

Open
mcourteaux opened this issue Nov 5, 2021 · 3 comments
Open

Make line wrapping and precision of tf.print configurable. #52960

mcourteaux opened this issue Nov 5, 2021 · 3 comments
Assignees
Labels
2.6.0 comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower type:feature Feature requests

Comments

@mcourteaux
Copy link

Please make sure that this is a feature request. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:feature_template

System information

  • TensorFlow version (you are using): not relevant
  • Are you willing to contribute it (Yes/No): Yes

Describe the feature and the current behavior/state.
tf.print() wraps past the 4th element for me. Output from printing an (N, 7, 7), where N=2 in this case, looks like this:

[[[ 5.62430954e+00 -3.49580956e+00 -8.04360168e+02 -5.40295654e+02
   -8.65279853e-01 -1.06588173e+00 -1.18294978e+00]
  [-3.49580956e+00  7.82608986e+00  4.73972961e+02  1.18741919e+03
    1.61477351e+00  1.88551021e+00  1.97545743e+00]
  [-8.04360168e+02  4.73972961e+02  1.31743172e+05  7.44966484e+04
    2.14444519e+02  2.22681152e+02  1.98635208e+02]
  [-5.40295654e+02  1.18741919e+03  7.44966484e+04  1.97479641e+05
    2.52062241e+02  2.85624451e+02  2.64948578e+02]
  [-8.65279853e-01  1.61477351e+00  2.14444519e+02  2.52062241e+02
    3.18258524e+00  2.82087207e+00  2.33711910e+00]
  [-1.06588173e+00  1.88551021e+00  2.22681152e+02  2.85624451e+02
    2.82087207e+00  2.64690948e+00  2.28564334e+00]
  [-1.18294978e+00  1.97545743e+00  1.98635208e+02  2.64948578e+02
    2.33711910e+00  2.28564334e+00  2.24237132e+00]]

 [[ 6.57234287e+00 -4.52555466e+00 -1.04999585e+03 -7.79698792e+02
   -1.47998118e+00 -2.11049843e+00 -4.34581661e+00]
  [-4.52555466e+00  8.80841637e+00  7.03340576e+02  1.52776123e+03
    2.77018666e+00  3.56193233e+00  6.32034349e+00]
  [-1.04999585e+03  7.03340576e+02  1.78551625e+05  1.23507805e+05
    4.00629730e+01  1.89105148e+02  5.56380432e+02]
  [-7.79698792e+02  1.52776123e+03  1.23507805e+05  2.79413969e+05
    3.76035431e+02  5.24331360e+02  1.04614160e+03]
  [-1.47998118e+00  2.77018666e+00  4.00629730e+01  3.76035431e+02
    1.25411425e+01  1.00502367e+01  9.19474983e+00]
  [-2.11049843e+00  3.56193233e+00  1.89105148e+02  5.24331360e+02
    1.00502367e+01  9.68517876e+00  1.09725800e+01]
  [-4.34581661e+00  6.32034349e+00  5.56380432e+02  1.04614160e+03
    9.19474983e+00  1.09725800e+01  1.55766268e+01]]]

I work a lot with these fixed-sized matrices (eg: 7x7, or 9x9). Debugging those is hard with line wrapping.
I'd like to get them all 7 elements of the matrix row on one line, at least. Additionally, I would fancy having less precision, as that is not that informative to debug.

Will this change the current api? How?
Either have like numpy a set_print_options(), or have extra arguments to tf.print along the lines of line_length=None (where None means "no wrapping at all") and format="%12.7e" where I could specify for example format="%10.4f".
I am slightly in favor of the custom options per tf.print() call to allow granular control.

Who will benefit with this feature?
Most likely anyone debugging stuff with matrices.

@mcourteaux mcourteaux added the type:feature Feature requests label Nov 5, 2021
@tensorflow tensorflow deleted a comment from SuyunCDN Nov 5, 2021
@sachinprasadhs
Copy link
Contributor

I don't think it is the limitation of tf.print, even if you try with normal print in colab, it truncates to certain numbers in a line.
You could just try the below line in your IDE.
print(np.random.randn(2,7,7))

@sachinprasadhs sachinprasadhs added 2.6.0 comp:ops OPs related issues stat:awaiting response Status - Awaiting response from author labels Nov 5, 2021
@google-ml-butler
Copy link

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.

@google-ml-butler google-ml-butler bot added the stale This label marks the issue/pr stale - to be closed automatically if no activity label Nov 12, 2021
@mcourteaux
Copy link
Author

mcourteaux commented Nov 13, 2021

@sachinprasadhs This is completely beside the point. I'm printing TensorFlow tensors with tf.print(). I'm not dealing with numpy arrays being printed by the regular Python print().

@google-ml-butler google-ml-butler bot removed stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author labels Nov 13, 2021
@sachinprasadhs sachinprasadhs added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.6.0 comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower type:feature Feature requests
Projects
None yet
Development

No branches or pull requests

3 participants