python 3.x - Reshaping in julia -
If I resize in Python then I use it:
Import nppy np y = np .asarray ([1,2,3,4,5,6,7,8]) x = 2 z = y.reshape (-1, x) print (z) and get it
& gt; & Gt; & Gt; [[1 2] [3 4] [5 6] [7 8]] How do I get the same thing in Julia? I tried:
z = [1,2,3,4,5,6,7,8] x = 2 a = reshape (z, x, 4) println (a) And he gave me:
[1 3 5 7 2 4 6 8] If I < Code> Resize (z, 4, x) to give it
[1 5 2 6 3 7 4 8] Is there a way to reshape without specifying another dimension such as reshape (z, x) , or is the secondary dimension more ambiguous?
how about
z = [1,2,3 , 4,5,6,7,8] x = 2 a = reshape (jade, x, 4) ' which gives
julia & Gt; A = reshape (z, x, 4) '4x2 array {int64,2}: 1 2 3 4 5 6 7 8 For your bonus question
"However, is there a way to reshape without specifying the second dimension such as reshape (z, x) or the secondary dimension is more ambiguous?"
The answer is not at all, because it would be unclear: reshape 3d, 4d, ..., can tensors, so it is not clear that What is expected
matrix_arapp (z, x) = reshape (z, x, div (length (z), x) can do something like, Looks like you expect.
Comments
Post a Comment