reshape_tensor | R Documentation |
Reshape input x and target y. Aggregates multiple samples from x and y into single input/target batches.
reshape_tensor(
x,
y,
new_batch_size,
samples_per_target,
buffer_len = NULL,
reshape_mode = "time_dist",
check_y = FALSE
)
x |
3D input tensor. |
y |
2D target tensor. |
new_batch_size |
Size of first axis of input/targets after reshaping. |
samples_per_target |
How many samples to use for one target |
buffer_len |
Only applies if |
reshape_mode |
|
check_y |
Check if entries in |
A list of 2 tensors.
# create dummy data
batch_size <- 8
maxlen <- 11
voc_len <- 4
x <- sample(0:(voc_len-1), maxlen*batch_size, replace = TRUE)
x <- keras::to_categorical(x, num_classes = voc_len)
x <- array(x, dim = c(batch_size, maxlen, voc_len))
y <- rep(0:1, each = batch_size/2)
y <- keras::to_categorical(y, num_classes = 2)
y
# reshape data for multi input model
reshaped_data <- reshape_tensor(
x = x,
y = y,
new_batch_size = 2,
samples_per_target = 4,
reshape_mode = "multi_input")
length(reshaped_data[[1]])
dim(reshaped_data[[1]][[1]])
reshaped_data[[2]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.