Skip to content

RNN trainr issue #32

Open
Open

Description

@vasgupta

Hello, I am getting an error running the trainr command in the package. Here it is:

Error in if (dim(X)[2] != dim(Y)[2] && !seq_to_seq_unsync) { :
missing value where TRUE/FALSE needed

Even though X and Y are the same length. I have copied the R file with my code:

library(rnn)
library(corrplot)
prices <- read.csv('A:\Vasu\Big Data Masters\MRP\Clean Input.csv')

prices$Date <- NULL
prices$Gold.Price <- as.numeric(gsub(",","", as.character(just_prices$Gold.Price), fixed = TRUE))
prices$DJIA <- as.numeric(gsub(",","", as.character(just_prices$DJIA), fixed = TRUE))

matrix <- cor(prices)
corrplot(matrix, method = "circle")
model <- trainr(Y = array(prices$Gold.Price), X = array(prices$US.Dollar.Index) , learningrate = 0.1,
sigmoid = 'logistic', use_bias = T)

Activity

  1. bquast commented on Jun 21, 2018

    @bquast
    Owner

    @DimitriF any thoughts?

  2. DimitriF commented on Jun 21, 2018

    @DimitriF
    Contributor

    I think array without the dim argument will return a array with one dimension, it seems you have only one sample, this should work better:

    model <- trainr(Y = array(prices$Gold.Price,dim=c(1,nrow(prices)), X = array(prices$US.Dollar.Index,dim=c(1,nrow(prices)) , learningrate = 0.1,
    sigmoid = 'logistic', use_bias = T)
    
    
  3. vasgupta commented on Jun 21, 2018

    @vasgupta
    Author

    Thanks @DimitriF it worked!

  4. vasgupta commented on Jun 21, 2018

    @vasgupta
    Author

    But just one more question, what if I wanted to input 3 variables, instead of one?
    I tried this, but its not working.

    model <- trainr(Y = array(prices$Gold.Price,dim=c(1,nrow(prices))),
    X = array(c(prices$US.Dollar.Index, prices$CBOE.Volatility, prices$Silver.Price),
    dim=c(3,nrow(prices))) , learningrate = 0.1,
    sigmoid = 'logistic', use_bias = T)

  5. DimitriF commented on Jun 21, 2018

    @DimitriF
    Contributor

    the first dimension is for the number of samples, the second for the number of elements in the sequence and the optional third dimension for the number of variables (if only 2 dimensions, yu have only one variable), so it should look like this:

    model <- trainr(Y = array(prices$Gold.Price,dim=c(1,nrow(prices))),
    X = array(c(prices$US.Dollar.Index, prices$CBOE.Volatility, prices$Silver.Price),
    dim=c(1,nrow(prices),3)) , learningrate = 0.1,
    sigmoid = 'logistic', use_bias = T)
    

    But I am not sure how array fill itself so you may have to use aperm to check

  6. vasgupta commented on Jun 29, 2018

    @vasgupta
    Author

    Hey, just wanted to clarify an issue I was getting.
    I'm running the RNN with just one variable and I convert all my inputs to binary before training on the RNN. However, in the output I was expecting a binary output, but it gave me a decimal answer. How can I fix this?

    Here's my code:

    prices <- read.csv('A:\Vasu\Big Data Masters\MRP\Clean Input.csv')

    prices$Date <- NULL
    prices$Gold.Price <- as.numeric(gsub(",","", as.character(just_prices$Gold.Price), fixed = TRUE))
    prices$DJIA <- as.numeric(gsub(",","", as.character(just_prices$DJIA), fixed = TRUE))

    matrix <- cor(prices)
    corrplot(matrix, method = "circle")

    convert integer prices to binary

    Y <- int2bin(prices$Gold.Price)
    X <- int2bin(prices$US.Dollar.Index)
    test <- int2bin(Test_prices$US.Dollar.Index)

    model <- trainr(Y = Y,
    X = X , learningrate = 0.1,
    sigmoid = 'logistic', use_bias = T)

    result <- predictr(model, test)

  7. DimitriF commented on Jun 30, 2018

    @DimitriF
    Contributor

    round(result) ?

  8. vasgupta commented on Jun 30, 2018

    @vasgupta
    Author

    My results look like this:

    results table

  9. bquast commented on Jun 30, 2018

    @bquast
    Owner

    All below 0.5? There must be another problem then

  10. vasgupta commented on Jun 30, 2018

    @vasgupta
    Author

    Does the input have to be in binary?

  11. vasgupta commented on Jun 30, 2018

    @vasgupta
    Author

    As well the int2bin function doesn't properly convert the integer to binary, it gives a wrong number.

  12. bquast commented on Jul 2, 2018

    @bquast
    Owner

    Not the input, nor the output has to be binary, the binary stuff is simply an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions