apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.78k stars 6.79k forks source link

Error in mx.io.internal.arrayiter(as.array(data), as.array(label), unif.rnds, : io.cc:54: Data and label shape in-consistent #7026

Closed kaushalx closed 6 years ago

kaushalx commented 7 years ago

Hi, I am trying to implement CNN in retail data to extract feature and item demand prediction. Data: has columns Price, Sale_flat,page, item size, Category, item id, Quantity( target var)..etc dim(train_mat) [1] 3184 104 dim(train.y) [1] 3184 1

For bugs or installation issues, please provide the following information. The more information you provide, the more likely people will be able to help you.

Environment info

Operating System: Window

Compiler: Rstudio

Package used (Python/R/Scala/Julia): R

library(caret) library(glmnet) library(maxnet) library(mxnet) library(ggplot2) library(dummies) library(clusterSim)

MXNet version:

Or if installed from source:

MXNet commit hash (git rev-parse HEAD):

If you are using python package, please provide

Python version and distribution:

If you are using R package, please provide

R sessionInfo():R version 3.4.0 (2017-04-21) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] reshape_0.8.6 clusterSim_0.45-2 MASS_7.3-47 cluster_2.0.6 maxnet_0.1.2
[6] glmnet_2.0-10 foreach_1.4.3 Matrix_1.2-9 caret_6.0-76 dummies_1.5.6
[11] mxnet_0.10.1 ggplot2_2.2.1 lattice_0.20-35

loaded via a namespace (and not attached): [1] viridis_0.4.0 jsonlite_1.5 viridisLite_0.2.0 splines_3.4.0 modeest_2.1
[6] shiny_1.0.3 assertthat_0.2.0 stats4_3.4.0 quantreg_5.33 glue_1.1.1
[11] digest_0.6.12 RColorBrewer_1.1-2 R2HTML_2.3.2 minqa_1.2.4 colorspace_1.3-2
[16] htmltools_0.3.6 httpuv_1.3.5 plyr_1.8.4 XML_3.98-1.9 pkgconfig_2.0.1
[21] SparseM_1.77 DiagrammeR_0.9.0 xtable_1.8-2 scales_0.4.1 brew_1.0-6
[26] lme4_1.1-13 MatrixModels_0.4-1 tibble_1.3.3 mgcv_1.8-17 car_2.1-4
[31] influenceR_0.1.0 nnet_7.3-12 lazyeval_0.2.0 pbkrtest_0.4-7 rgexf_0.15.3
[36] mime_0.5 magrittr_1.5 nlme_3.1-131 class_7.3-14 Rook_1.1-1
[41] tools_3.4.0 stringr_1.2.0 munsell_0.4.3 bindrcpp_0.2 ade4_1.7-6
[46] compiler_3.4.0 e1071_1.6-8 rlang_0.1.1 grid_3.4.0 nloptr_1.0.4
[51] iterators_1.0.8 rstudioapi_0.6 htmlwidgets_0.8 visNetwork_2.0.0 igraph_1.0.1
[56] gtable_0.2.0 ModelMetrics_1.1.0 codetools_0.2-15 reshape2_1.4.2 R6_2.2.2
[61] gridExtra_2.2.1 knitr_1.16 dplyr_0.7.1 bindr_0.1 stringi_1.1.5
[66] parallel_3.4.0 Rcpp_0.12.11 rgl_0.98.1

Error Message: Error in mx.io.internal.arrayiter(as.array(data), as.array(label), unif.rnds, :

io.cc:54: Data and label shape in-consistent

Please paste the full error message, including stack trace. Error in mx.io.internal.arrayiter(as.array(data), as.array(label), unif.rnds, : io.cc:54: Data and label shape in-consistent

traceback()

Error in mx.io.internal.arrayiter(as.array(data), as.array(label), unif.rnds, : io.cc:54: Data and label shape in-consistent 6: stop(list(message = "io.cc:54: Data and label shape in-consistent\n", call = mx.io.internal.arrayiter(as.array(data), as.array(label), unif.rnds, batch.size, shuffle), cppstack = list(file = "", line = -1L, stack = "C++ stack not available on this system"))) 5: .External(list(name = "InternalFunction_invoke", address = <pointer: 0x000000000c6d9ae0>, dll = list(name = "Rcpp", path = "C:/Users/Sanjeev/Documents/R/win-library/3.4/Rcpp/libs/x64/Rcpp.dll", dynamicLookup = TRUE, handle = <pointer: 0x000000006abc0000>, info = <pointer: 0x00000000026553b0>), numParameters = -1L), <pointer: 0x0000000002c86790>, ...) 4: mx.io.internal.arrayiter(as.array(data), as.array(label), unif.rnds, batch.size, shuffle) 3: mx.io.arrayiter(X, y, batch.size = batch.size, shuffle = is.train) 2: mx.model.init.iter(X, y, batch.size = array.batch.size, is.train = TRUE) 1: mx.model.FeedForward.create(symbol = output, X = as.matrix(train_mat), y = train.y, ctx = mx.cpu(), num.round = 100, optimizer = "sgd", array.batch.size = 50, learning.rate = 0.01, momentum = 0.9, eval.metric = mx.metric.rmse, array.layout = "rowmajor", verbose = TRUE)## Minimum reproducible example if you are using your own code, please provide a short script that reproduces the error. train_ind <- sample(1:nrow(df2), round(.75*(nrow(df2))))

train.x <- as.matrix(df2[train_ind,!(names(df2)%in% Noinputcolname)])

Normlizing training data

train.x <-data.Normalization(train.x,type = "n4")

test.x <- as.matrix(df2[-train_ind,!(names(df2)%in% Noinputcolname)])

Normalizing test data

test.x <- data.Normalization(test.x,type = "n4")

train.y <- as.matrix(df2[train_ind,target])

Normlizing train target/label data

train.y <-data.Normalization(train.y,type = "n4")

test.y <- as.numeric(df2[-train_ind,target])

Normlizing test target data

test.y <- data.Normalization(test.y,type="n4")

######## Defining dim arrary for input to CNN model

library(reshape2)

library(reshape) train_mat <- train.x

dim(train_mat) <- c(1,104,1,nrow(train.x))

dim(train_mat) <- c(104,nrow(train.x))

dim(test.array)<- c(1,104,1,nrow(test.x))

mx.set.seed(123)

model <- mx.model.FeedForward.create(symbol = output, X = as.matrix(train_mat), y = train.y, ctx = mx.cpu(), num.round = 100, optimizer = "sgd", array.batch.size = 50, learning.rate = 0.01, momentum = 0.9, eval.metric = mx.metric.rmse, array.layout = "rowmajor", verbose = TRUE )

Steps to reproduce

or if you are running standard examples, please provide the commands you have run that lead to the error.

1. 2. 3.

What have you tried to solve it?

  1. I tried to take transpose of train data : X = t(as.matrix(train_mat)),
  2. i tried to reshape train data dim. dim(train_mat) <- c(104,1,nrow(train_mat))
thirdwing commented 7 years ago

Please provide a reproducible example. We don't know what df2 is.

anirudhacharya commented 6 years ago

@sandeep-krishnamurthy please close this issue as the OP has been inactive for more than a year, and there is no reproducible example for this.