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

Two (small) issues with display of tensor #500

Closed
pietroppeter opened this issue Mar 12, 2021 · 2 comments
Closed

Two (small) issues with display of tensor #500

pietroppeter opened this issue Mar 12, 2021 · 2 comments

Comments

@pietroppeter
Copy link

pietroppeter commented Mar 12, 2021

example (playground):

import arraymancer, sequtils
echo toSeq(1..24).toTensor().reshape(2,3,4)

output:

Tensor[system.int] of shape [2, 3, 4]" on backend "Cpu"
| | 	1	2	3	4 | 	13	14	15	16|
| | 	5	6	7	8 | 	17	18	19	20|
| | 	9	10	11	12 | 	21	22	23	24|

The two issues are:

  1. an additional " after tensor shape
  2. and additional set of | in first columns

First one is a trivial fix (source); the second one might be a little be more involved (source), but I could try to produce a PR with a fix for both.

Also, not sure what should be the expected display of a 4d tensor, an example:

import arraymancer, sequtils
echo toSeq(1..16).toTensor().reshape(2,2,2,2)

output:

Tensor[system.int] of shape [2, 2, 2, 2]" on backend "Cpu"
|						|
|-	-	-	-	-	-	-|
| | 	1	2 | 	5	6|
| | 	3	4 | 	7	8|
|-	-	-	-	-	-	-|
| | 	9	10 | 	13	14|
| | 	11	12 | 	15	16|

I noticed these two issues while writing a remake of the Tutorial using a library I am developing: nimib.

I also noticed this very interesting issue #488 which is relevant to documentation and for which maybe nimib in the future (I am close to first release of 0.1) might be able to help with.

@mratsim
Copy link
Owner

mratsim commented Mar 13, 2021

Unfortunately 4D display on a 2D screen is a bit hard. Ideally 4D display looks like that #5 (comment)

image

I try to reverse engineer the Haskell code of that library but got lost in Monads :/.

Regarding nimib, you might want to have a chat with @haxscramper as he also wanted to help tackle that part (and many others tooling issues like nimble dependencies resolution), https://github.com/haxscramper/haxdoc

@Vindaar
Copy link
Collaborator

Vindaar commented Dec 29, 2021

Since #509 (and some fixes of it after) the first example now gives:

import arraymancer, sequtils
echo toSeq(1..24).toTensor().reshape(2,3,4)
Tensor[system.int] of shape "[2, 3, 4]" on backend "Cpu"                                                           
          0                      1                                                                                 
|1      2     3     4| |13    14    15    16|                                                                      
|5      6     7     8| |17    18    19    20|
|9     10    11    12| |21    22    23    24| 

and the second:

import arraymancer, sequtils
echo toSeq(1..16).toTensor().reshape(2,2,2,2)
Tensor[system.int] of shape "[2, 2, 2, 2]" on backend "Cpu"
      0          1     
0 |1      2| |5      6|
  |3      4| |7      8|
  ---------------------
      0          1     
1 |9     10| |13    14|
  |11    12| |15    16|
  ---------------------

I'll close the issue for now. If I'm missing something that is still broken, feel free to reopen.

@Vindaar Vindaar closed this as completed Dec 29, 2021
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

3 participants