You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/08/13 22:10:32 UTC

[GitHub] ArturIndio opened a new issue #7446: format input data using mx.rnn

ArturIndio opened a new issue #7446: format input data using mx.rnn
URL: https://github.com/apache/incubator-mxnet/issues/7446
 
 
   
   [data_ex_git.zip](https://github.com/apache/incubator-mxnet/files/1220978/data_ex_git.zip)
   I've trying to forecast time-series using mx.rnn model but I can't shape the data to input  format asked from mx.rnn. I want do predict a variable Q_t using some past values from itself and another variables. Using mx.model.FeedForward.create is very easy to define. I can't understand the "labels" input on mx.rnn model. This is my code:
   
   ```
   load("data_ex_git.RData") # attached
   
   
   train <- data[1:dias_train,]
   test <- data[(dias_train+1):nrow(data),]
   
   # Neural net fitting
   
   # Scaling data for the NN
   maxs <- apply(data, 2, max)
   mins <- apply(data, 2, min)
   scaled <- as.data.frame(scale(data, center = mins, scale = maxs - mins))
   
   train_ <- scaled[1:dias_train,]
   test_ <- scaled[(dias_train+1):nrow(data),]
   
   library(mxnet)
   train.x <- data.matrix(train_[,-1])
   train.y <- train_[,1]
   test.x <- data.matrix(test_[,-1])
   test.y <- test_[,1]
   
   X.train <- list(data=t(train.x), label=t(train.y))
   X.val <- list(data=t(test.x), label=t(test.y))
   
   batch.size = 5
   seq.len = 5
   num.hidden = 3
   num.embed = 3
   num.rnn.layer = 1
   num.lstm.layer = 1
   num.round = 1
   update.period = 1
   learning.rate= 0.1
   wd=0.00001
   clip_gradient=1
   
   mx.set.seed(0)
   model <- mx.rnn(X.train, NULL, num.rnn.layer=num.rnn.layer, seq.len=seq.len, num.hidden=num.hidden,
                   num.embed=num.embed, num.label=5, batch.size=batch.size, input.size=5, ctx = mx.cpu(),
                   num.round = num.round, update.period = update.period, initializer = mx.init.uniform(0.01),
                   dropout = 0, optimizer = "sgd", batch.norm = FALSE,
                   learning.rate=learning.rate, wd=wd, clip_gradient=clip_gradient)
   
   preds = predict(model,t(test.x))
   ```
   That's my error:
   
   `[19:10:06] d:\program files (x86)\jenkins\workspace\mxnet\mxnet\src\operator\tensor\./matrix_op-inl.h:141: Using target_shape will be deprecated.
   [19:10:06] d:\program files (x86)\jenkins\workspace\mxnet\mxnet\src\operator\tensor\./matrix_op-inl.h:141: Using target_shape will be deprecated.
   [19:10:06] d:\program files (x86)\jenkins\workspace\mxnet\mxnet\src\operator\tensor\./matrix_op-inl.h:141: Using target_shape will be deprecated.
   [19:10:06] D:\Program Files (x86)\Jenkins\workspace\mxnet\mxnet\dmlc-core\include\dmlc/logging.h:308: [19:10:06] D:\Program Files (x86)\Jenkins\workspace\mxnet\mxnet\src\ndarray\ndarray.cc:329: Check failed: from.shape() == to->shape() operands shape mismatchfrom.shape = (5,14) to.shape=(5,5)
   Error in exec$update.arg.arrays(arg.arrays, match.name, skip.null) : 
     [19:10:06] D:\Program Files (x86)\Jenkins\workspace\mxnet\mxnet\src\ndarray\ndarray.cc:329: Check failed: from.shape() == to->shape() operands shape mismatchfrom.shape = (5,14) to.shape=(5,5)`
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services