About 5,850,000 results
Open links in new tab
  1. How do I get the value of a tensor in PyTorch? - Stack Overflow

    Aug 30, 2019 · 1.0 To get a value from non single element tensor we have to be careful: The next example will show that PyTorch tensor residing on CPU shares the same storage as numpy array na …

  2. python - PyTorch preferred way to copy a tensor - Stack Overflow

    Mar 20, 2019 · Gradients propagating to the cloned tensor will propagate to the original tensor. So while .clone() returns a copy of the data it keeps the computation graph and records the clone operation in …

  3. python - How to print the value of a Tensor object in TensorFlow ...

    Nov 10, 2015 · The easiest [A] way to evaluate the actual value of a Tensor object is to pass it to the Session.run() method, or call Tensor.eval() when you have a default session (i.e. in a with …

  4. What does `-1` of `view ()` mean in PyTorch? - Stack Overflow

    Jun 11, 2018 · If you had tensor.view(-1, Dnew) it would produce a tensor of two dimensions/indices but would make sure the first dimension to be of the correct size according to the original dimension of …

  5. python - Convert a tensor to numpy array in Tensorflow? - Stack …

    Dec 4, 2015 · How to convert a tensor into a numpy array when using Tensorflow with Python bindings?

  6. python - `squeeze ()` vs `unsqueeze ()` in PyTorch - Stack Overflow

    I don't understand what squeeze() and unsqueeze() do to a tensor, even after looking at the docs and related questions. I tried to understand it by exploring it myself in python. I first created a ...

  7. python - What does `view ()` do in PyTorch? - Stack Overflow

    Aug 21, 2024 · 18 torch.Tensor.view() Simply put, torch.Tensor.view() which is inspired by numpy.ndarray.reshape() or numpy.reshape(), creates a new view of the tensor, as long as the new …

  8. python - How to multiply matrices in PyTorch? - Stack Overflow

    Jun 13, 2017 · a = torch.ones((3, 2)) b = torch.ones((2, 1)) result = torch.dot(a, b) This code throws the following error: RuntimeError: 1D tensors expected, but got 2D and 2D tensors How do I perform …

  9. Converting python list to pytorch tensor - Stack Overflow

    Feb 6, 2020 · I have a problem converting a python list of numbers to pytorch Tensor : this is my code : caption_feat = [int(x) if x < 11660 else 3 for x in caption_feat] printing caption_feat gives : [1,

  10. python - What does "unsqueeze" do in Pytorch? - Stack Overflow

    Jul 28, 2019 · 0 In PyTorch (and other frameworks like NumPy), unsqueeze () is used to add a dimension to a tensor at a specific position, effectively increasing the number of dimensions of the …