In rnn package in R, the example shows how to train a RNN with numeric input variables.
The example code is:
library('rnn')
# create training numbers
set.seed(1)
X1 = sample(0:127, 7000, replace=TRUE)
X2 = sample(0:127, 7000, replace=TRUE)
# create training response numbers
Y <- X1 + X2
# convert to binary
X1 <- int2bin(X1, length=8)
X2 <- int2bin(X2, length=8)
Y  <- int2bin(Y,  length=8)
# create 3d array: dim 1: samples; dim 2: time; dim 3: variables
X <- array( c(X1,X2), dim=c(dim(X1),2) )
# train the model
model <- trainr(Y=Y,
                X=X,
                learningrate   =  0.1,
                hidden_dim     = 10,
                start_from_end = TRUE )
In the above example, X1 and X2 are numerical variables.
How can I train a RNN model in R if the input variables are factor?
Thanks a lot,
 
     
    