Flip a Tensor
See original GitHub issueArea Select
react-native-pytorch-core (core package)
Description
Hi, thanks for contributions.
How can i flip a tensor like torch.flip? There is no implementation of flip function in Playtorch docs
Another solution i thought is to make a new tensor and assign reversed values using for loop
such as the tensor[::, ::-1]
.
However, i got a result Cannot assign to property ~
My code and the corresponding error are as follows.
CODE: e.g., (.js file)
let tempTensor = torch.zeros(1);
console.log('temp value', tempTensor.data());
console.log('temp shape', tempTensor.shape);
tempTensor[0].data = 5; //or tempTensor[0]
console.log('result', tempTensor.data());
ERROR: e.g.,
LOG temp value [0]
LOG temp shape [1]
WARN Possible Unhandled Promise Rejection (id: 10):
Error: Exception in HostObject::set for prop 'data': TypeError: Cannot assign to property 'data' on HostObject with default setter
How can i solve this problem? Many thanks for your help :)
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
torch.flip — PyTorch 1.13 documentation
torch.flip ... Reverse the order of a n-D tensor along given axis in dims. ... torch.flip makes a copy of input 's data....
Read more >How to Reverse Order of Rows in a Tensor - Stack Overflow
According to documentation torch.flip has argument dims , which control what axis to be flipped. In this case torch.flip(tensor_a, ...
Read more >flip a Tensor · Issue #229 · pytorch/pytorch - GitHub
I've been timing a number of options for flipping a tensor and so far, the fastest on my GPU has been either explicit...
Read more >tf.reverse | TensorFlow v2.11.0
Given a tensor , and a int32 tensor axis representing the set of dimensions of tensor to reverse. This operation reverses each dimension...
Read more >Machine Learning — PyTorch - Medium
2. torch.flip(input, dims) ... It reverse the order of a n-D tensor along given axis in dims. It requires two argument, the first...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@raedle, Thank you so much 😄 My app gets a fliped image, so i have to flip image before our models infer this image. In detail, my app will use
tensor.permute ([2,1,0])
andflip
, because it receives images rotated 90 degrees. I will report back if I have any questions or if this problem is solved.Fantastic to hear, @nh9k! I’ll close the issue, then