Skip to contents

One-hot encoding matrix to n-gram encoding matrix

Usage

n_gram_of_matrix(input_matrix, n = 3)

Arguments

input_matrix

Matrix with one 1 per row and zeros otherwise.

n

Length of one n-gram.

Value

Matrix of one-hot encodings.

Examples

if (FALSE) { # reticulate::py_module_available("tensorflow")
x <- c(0,0,1,3,3) 
input_matrix <- keras::to_categorical(x, 4)
n_gram_of_matrix(input_matrix, n = 2) 
}