bquast / rnn

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

Error when running predictr example #18

Closed SatoshiReport closed 7 years ago

SatoshiReport commented 7 years ago

I install rnn with:

install.packages("rnn")

and I get:

trying URL 'https://mran.revolutionanalytics.com/snapshot/2016-01-01/bin/macosx/mavericks/contrib/3.2/rnn_0.2.0.tgz'
Content type 'application/octet-stream' length 20977 bytes (20 KB)
==================================================
downloaded 20 KB

The downloaded binary packages are in
    /var/folders/gw/n5ng_2z528ncn47473zvfk_h0000gn/T//RtmpzkUE9d/downloaded_packages

I then take the example for predictr from https://cran.r-project.org/web/packages/rnn/rnn.pdf

library(rnn)

## Not run:
# create training numbers
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)
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) )
# train the model
model <- trainr(Y=Y[,dim(Y)[2]:1],
                X=X[,dim(X)[2]:1,],
                learningrate = 0.1,
                hidden_dim = 10
)
# create test inputs
A1 = int2bin( sample(0:127, 7000, replace=TRUE) )
A2 = int2bin( sample(0:127, 7000, replace=TRUE) )
# create 3d array: dim 1: samples; dim 2: time; dim 3: variables
A <- array( c(A1,A2), dim=c(dim(A1),2) )
# predict
B <- predictr(model,
              A[,dim(A)[2]:1,] )
B = B[,dim(B)[2]:1]
# convert back to integers
A1 <- bin2int(A1)
A2 <- bin2int(A2)
B <- bin2int(B)
# inspect the differences
table( B-(A1+A2) )
# plot the difference
hist( B-(A1+A2) )
## End(Not run)

and I receive the following error:

Error in eval(expr, envir, enclos) : could not find function "int2bin"

Any idea on how I can resolve? I am thinking the install process is the culprit.

bquast commented 7 years ago

Hi,

Sorry that is an old example, that function doesn't exist anymore. Have a look at the vignettes.

B

On Sun, Nov 13, 2016, 16:48 SatoshiReport notifications@github.com wrote:

I install rnn with:

install.packages("rnn")

and I get:

trying URL 'https://mran.revolutionanalytics.com/snapshot/2016-01-01/bin/macosx/mavericks/contrib/3.2/rnn_0.2.0.tgz'

Content type 'application/octet-stream' length 20977 bytes (20 KB)

downloaded 20 KB

The downloaded binary packages are in /var/folders/gw/n5ng_2z528ncn47473zvfk_h0000gn/T//RtmpzkUE9d/downloaded_packages

I then take the example for predictr from https://cran.r-project.org/web/packages/rnn/rnn.pdf

library(rnn)

Not run:

create training numbers

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) 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) )

train the model

model <- trainr(Y=Y[,dim(Y)[2]:1], X=X[,dim(X)[2]:1,], learningrate = 0.1, hidden_dim = 10 )

create test inputs

A1 = int2bin( sample(0:127, 7000, replace=TRUE) ) A2 = int2bin( sample(0:127, 7000, replace=TRUE) )

create 3d array: dim 1: samples; dim 2: time; dim 3: variables

A <- array( c(A1,A2), dim=c(dim(A1),2) )

predict

B <- predictr(model, A[,dim(A)[2]:1,] ) B = B[,dim(B)[2]:1]

convert back to integers

A1 <- bin2int(A1) A2 <- bin2int(A2) B <- bin2int(B)

inspect the differences

table( B-(A1+A2) )

plot the difference

hist( B-(A1+A2) )

End(Not run)

and I receive the following error:

Error in eval(expr, envir, enclos) : could not find function "int2bin"

Any idea on how I can resolve? I am thinking the install process is the culprit.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bquast/rnn/issues/18, or mute the thread https://github.com/notifications/unsubscribe-auth/ACeGjcnSJVygfSje1kcaOjuJeTR8Ifvfks5q96_QgaJpZM4Kw3On .