Tensor-class: Tensor

Description Usage Format Value Fields Usage Public Methods Details Author(s)

Description

Tensor class providing methods for chaining operations to be evaluated lazily.

Usage

1
2
3
4
5
6
7

Format

R6Class object

Value

Object of R6Class with methods for symbolic operations

Fields

tensor

Stores the tensor object

name

The name of the Tensor object

graph

The graph containing the registered Nodes and Operations to be evaluated

Usage

1
2
3
4
5
rmat = matrix(rnorm(16), 4)
a = Tensor$new(rmat)
init = Tensor$new("RandomNormal", shape = c(4,4))
v = variable$new(rmat)
c = constant$new(rmat)

Public Methods

.dot(name = NA)

Dot product of two Tensors

.add(name = NA)

Addition of two Tensors

.sub(name = NA)

Subtraction of two Tensors

.mult(name = NA)

Elementwise multiplication of two Tensors

.div(name = NA)

Elementwise division of two Tensors

.eq(name = NA)

Elementwise equality of Tensors

.neq(name = NA)

Elementwise inequality of Tensors

.gte(name = NA)

Elementwise >= of Tensors

.gt(name = NA)

Elementwise > of Tensors

.lte(name = NA)

Elementwise <= of Tensors

.lt(name = NA)

Elementwise < of Tensors

pow(val,name = NA)

Power (^) of Tensor elements

log(base = exp(1))(name = NA)

Natural log of Tensor elements

log10(name = NA)

Log base 10 of Tensor elements

log1p(name = NA)

log(1+x) of Tensor elements

log2(name = NA)

Log base 2 of Tensor elements

exp(name = NA)

Exponential of Tensor elements

expm1(name = NA)

exp(x) - 1 of Tensor elements

sin(name = NA)

sin of Tensor elements

asin(name = NA)

asin of Tensor elements

sinh(name = NA)

sinh of Tensor elements

cos(name = NA)

cos of Tensor elements

acos(name = NA)

acos of Tensor elements

cosh(name = NA)

cosh of Tensor elements

tan(name = NA)

tan of Tensor elements

atan(name = NA)

atan of Tensor elements

tanh(name = NA)

tanh of Tensor elements

max(name = NA)

max of Tensor elements

min(name = NA)

min of Tensor elements

mean(name = NA)

mean of Tensor elements

abs(name = NA)

abs of Tensor elements

round(digits, name = NA)

round of Tensor elements

floor(name = NA)

floor of Tensor elements

ceiling(name = NA)

ceiling of Tensor elements

sqrt(name = NA)

sqrt of Tensor elements

sign(name = NA)

sign of Tensor elements

sum(name = NA)

sum of Tensor elements

cumsum(name = NA)

cumulative sum of Tensor elements

prod(name = NA)

product of Tensor elements

cumprod(name = NA)

cumulative product of Tensor elements

compute(feed_list)

Compute/Evaluate the Tensor graph

chain(f)(name = NA)

Process a function to be evaluated within the Tensor graph

drop(idx = NA, name = NA)

Drop a previously added operation from the Tensor graph

has_history

returns boolean indicating of additional Tensor involved in graph

Details

Tensor is the base class of this package (based upon R6). The Placeholder, variable, and constant are all child class of the Tensor class.

There are only minor differences with the variable and constant child classes. variable instances have their shape fixed. The internal data values may be changed but the shape of the Tensor is not allowed. As can be assumed, the constant child class does not allow any change to the underlying Tensor or the Tensor shape.

The Placeholder class is unique in that it contains NO underlying data. The class simply contains the shape of the intended Tensor. All chained methods are still applicable. The user is recommended to provide a name to the initialized Placeholder as when the final compute method is called, the operations will look for a passed named list element in the compute{feed_list = list()} call. This allows the user to provide alternate datasets to a previously prototyped process. This mirrors the functionality of libraries such as Tensorflow.

Author(s)

Charles Determan Jr.


cdeterman/lazytensor documentation built on May 28, 2019, 7:15 p.m.