tensor_ops: Two tensor operations

Description Usage Arguments Methods (by class) Examples

View source: R/generics.R

Description

Two tensor operations

Usage

1
2
3
4
tensor_ops(a, b)

## S3 method for class 'torch.Tensor'
a ^ b

Arguments

a

tensor

b

tensor

Methods (by class)

Examples

 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
## Not run: 
a <- torch$Tensor(list(1, 1, 1))
b <- torch$Tensor(list(2, 2, 2))
s <- 2.0
a + b
b - a
a * b
a / s
a == b
a == a
a != a
x <- torch$Tensor(list(list(2, 2, 2), list(4, 4, 4)))
y <- torch$Tensor(list(list(1, 2, 1), list(3, 4, 5)))
x > y
x < y
x >= y
y <= x
diag <- torch$eye(3L)
zeros <- torch$zeros(c(3L, 3L))
diag & zeros
diag & diag
diag | diag
zeros | zeros
zeros & zeros
diag & zeros
diag | zeros

## End(Not run)
## Not run: 
x <- torch$arange(1,11)
torch$pow(x, 2)      #     x^(2)
torch$pow(x, -2)     #     x^(1/2)

## End(Not run)

rTorch documentation built on Jan. 13, 2021, 4:32 p.m.