tests/testthat/_snaps/tensor.md

print tensor is truncated

torch_tensor
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
... [the output was truncated (use n=-1 to disable)]
[ CPUFloatType{100} ]
torch_tensor
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
[ CPUFloatType{25} ]
torch_tensor
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
... [the output was truncated (use n=-1 to disable)]
[ CPUFloatType{100} ]
torch_tensor
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
[ CPUFloatType{100} ]

print tensors with grad_fn and requires_grad

Code
  print(x)
Output
  torch_tensor
   1
   2
   3
  [ CPUFloatType{3} ]
Code
  print(y)
Output
  torch_tensor
   1
   2
   3
  [ CPUFloatType{3} ][ requires_grad = TRUE ]
Code
  print(z)
Output
  torch_tensor
   0.0000
   0.6931
   1.0986
  [ CPUFloatType{3} ][ grad_fn = <LogBackward0> ]

print complex tensors

Code
  print(x)
Output
  torch_tensor
  ℹ Use `$real` or `$imag` to print the contents of this tensor.
  [ CPUComplexFloatType{10} ]
Code
  print(x)
Output
  torch_tensor
  ℹ Use `$real` or `$imag` to print the contents of this tensor.
  [ CPUComplexFloatType{10} ][ requires_grad = TRUE ]
Code
  print(y)
Output
  torch_tensor
  ℹ Use `$real` or `$imag` to print the contents of this tensor.
  [ CPUComplexFloatType{10} ][ grad_fn = <MulBackward0> ]


Try the torch package in your browser

Any scripts or data that you put into this service are public.

torch documentation built on June 7, 2023, 6:19 p.m.