join_tensors: Join Multiple Tensors into One Tensor

View source: R/tensor.R

join_tensorsR Documentation

Join Multiple Tensors into One Tensor

Description

Join Multiple Tensors into One Tensor

Usage

join_tensors(tensors, temporary = TRUE)

Arguments

tensors

list of Tensor instances

temporary

whether to garbage collect space when exiting R session

Details

Merges multiple tensors. Each tensor must share the same dimension with the last one dimension as 1, for example, 100x100x1. Join 3 tensors like this will result in a 100x100x3 tensor. This function is handy when each sub-tensors are generated separately. However, it does no validation test. Use with cautions.

Value

A new Tensor instance with the last dimension

Author(s)

Zhengjia Wang

Examples

tensor1 <- Tensor$new(data = 1:9, c(3,3,1), dimnames = list(
A = 1:3, B = 1:3, C = 1
), varnames = c('A', 'B', 'C'))
tensor2 <- Tensor$new(data = 10:18, c(3,3,1), dimnames = list(
  A = 1:3, B = 1:3, C = 2
), varnames = c('A', 'B', 'C'))
merged <- join_tensors(list(tensor1, tensor2))
merged$get_data()


raveio documentation built on July 26, 2023, 5:29 p.m.