Closed Dxyk closed 7 months ago
Hi @Dxyk, this is a bug. However, for all practical applications, you don't have to transpose Φ-Flow tensors, as the dimension order is irrelevant for all functions (except for some plotting functions).
To get the transposed PyTorch tensor back, you can use test_tensor.native('y,x')
.
Hi, thanks for the reply. I have one more follow-up question - When visualizing a Field
, how do I rotate the field by 90 degrees?
Specifically, I have a 3D field with spatial(x, y, z)
. I would like to visualize the 2D field summed along the x-axis, so I do
vis.plot(math.sum(my_field.values, dim='x'), title="side view")
This gives me a plot with a horizontal y-axis and a verticle z-axis. How do I rotate/transpose the plot so that it gives me a horizontal z-axis and a vertical y-axis? Since transpose
doesn't work in this case, is there another workaround?
As a workaround, you could simply define
def transpose(x, order='y,x'):
return wrap(x.native(order), x.shape[order])
Perfect, that's exactly what I was looking for. Thanks for the help!
Hello,
I was experimenting with tensor transposes and found that it did not work the way I expected. Maybe I misunderstood something, but a bit of help is appreciated :) I'm currently on PhiFlow version 2.5.3, and PhiML version 1.2.1.
The corresponding PyTorch behaviour is
Thanks in advance for helping, and also thanks for the great work!