Uploaded image for project: ' Swift for TensorFlow'
  1. Swift for TensorFlow
  2. TF-419

[TF] Improve tensor printing

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Closed
    • Priority: Minor
    • Resolution: Done
    • Component/s: None
    • Labels:

      Description

      Current, calling print on a Tensor instance displays all of its scalars in a flat string.

      This is not ideal as the default printing behavior because the printed output is prohibitively long for large tensors:

      import TensorFlow
      let x = Tensor<Float>(ones: [100, 10])
      print(x)
      // [[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], ...
      

      At a minimum, we want:

      • Pretty printing. (Printing 1-D element vectors on new lines.)
      • Truncation. (Shortening overly long lines, hiding content with “...”.)

      Extended functionality:

      • Pretty printing formatter options.
      • A mechanism to do full-printing (like how printing is implemented today).
         

      Survey:

        Attachments

          Activity

            People

            Assignee:
            danzheng Dan Zheng
            Reporter:
            danzheng Dan Zheng
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: