[409433]: / man / n_gram_of_matrix.Rd

Download this file

27 lines (25 with data), 742 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/preprocess.R
\name{n_gram_of_matrix}
\alias{n_gram_of_matrix}
\title{One-hot encoding matrix to n-gram encoding matrix}
\usage{
n_gram_of_matrix(input_matrix, n = 3)
}
\arguments{
\item{input_matrix}{Matrix with one 1 per row and zeros otherwise.}
\item{n}{Length of one n-gram.}
}
\value{
Matrix of one-hot encodings.
}
\description{
One-hot encoding matrix to n-gram encoding matrix
}
\examples{
\dontshow{if (reticulate::py_module_available("tensorflow")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
x <- c(0,0,1,3,3)
input_matrix <- keras::to_categorical(x, 4)
n_gram_of_matrix(input_matrix, n = 2)
\dontshow{\}) # examplesIf}
}