bquast / rnn

Recurrent Neural Networks in R
https://qua.st/rnn
73 stars 28 forks source link

Does int2bin work with no "length" argument? #19

Closed georgeblck closed 7 years ago

georgeblck commented 7 years ago

Hi,

I was doing some stuff with the package starting with the rnn-Vignette and found a very minor issue in that document. I was trying to execute the example calculation and found that contrary to the code in the Vignette, the function int2bin(integer, length=time_dim) needs a second argument; in the Vignette it is left out. Here is the relevant, "broken" code so you can check it yourself:

library(rnn)
set.seed(1)
# create sample inputs
X1 = sample(0:127, 5000, replace=TRUE)
X2 = sample(0:127, 5000, replace=TRUE)

# create sample output
Y <- X1 + X2

# convert to binary
#### should return an error here
X1 <- int2bin(X1)
X2 <- int2bin(X2)
Y  <- int2bin(Y)

# Create 3d array: dim 1: samples; dim 2: time; dim 3: variables.
X <- array( c(X1,X2), dim=c(dim(X1),2) )
Y <- array( Y, dim=c(dim(Y),1) ) 

model <- trainr(Y=Y[,dim(Y)[2]:1,,drop=F], # we inverse the time dimension
                X=X[,dim(X)[2]:1,,drop=F], # we inverse the time dimension
                learningrate   =  0.1,
                hidden_dim     = 10,
                batch_size = 100,
                numepochs = 10)
bquast commented 7 years ago

hi, issues is not intended for questions, you can post a question on stackoverflow.com and send me the link at bquast@gmail.com