Learn R Programming

rTorch (version 0.4.2)

tensor_ops: Two tensor operations

Description

Two tensor operations

Usage

tensor_ops(a, b)

# S3 method for torch.Tensor ^(a, b)

Arguments

a

tensor

b

tensor

Methods (by class)

  • torch.Tensor: A tensor 'a' to the power of 'b'

Examples

Run this code
# 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
# }
# NOT RUN {
x <- torch$arange(1,11)
torch$pow(x, 2)      #     x^(2)
torch$pow(x, -2)     #     x^(1/2)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab