Created
December 21, 2016 18:20
-
-
Save skrish13/6ac66911916508c449fed2b769ddf28e to your computer and use it in GitHub Desktop.
Log of the R console for replicating #3736(dmlc/mxnet)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clean workspace | |
> rm(list=ls()) | |
> | |
> # Load MXNet | |
> require(mxnet) | |
> | |
> # Loading data and set up | |
> #------------------------------------------------------------------------------- | |
> | |
> # Load train and test datasets | |
> train <- read.csv("JAFFE_64_train_multi_label.csv") | |
> test <- read.csv("JAFFE_64_test_multi_label.csv") | |
> | |
> # Set up train and test datasets | |
> train <- data.matrix(train) | |
> train_x <- t(train[, -(1:6)]) | |
> train_y <- train[, 1:6] | |
> train_array <- train_x | |
> dim(train_array) <- c(64, 64, 1, ncol(train_x)) | |
> | |
> test_x <- t(test[, -(1:6)]) | |
> test_y <- test[, 1:6] | |
> test_array <- test_x | |
> dim(test_array) <- c(64, 64, 1, ncol(test_x)) | |
> # Set up the symbolic model | |
> #------------------------------------------------------------------------------- | |
> | |
> data <- mx.symbol.Variable('data') | |
> # 1st convolutional layer | |
> conv_1 <- mx.symbol.Convolution(data = data, kernel = c(5, 5), num_filter = 20) | |
> tanh_1 <- mx.symbol.Activation(data = conv_1, act_type = "tanh") | |
> #tanh_1 <- mx.symbol.SoftmaxActivation(data = conv_1) | |
> pool_1 <- mx.symbol.Pooling(data = tanh_1, pool_type = "max", kernel = c(2, 2), stride = c(2, 2)) | |
> # 2nd convolutional layer | |
> conv_2 <- mx.symbol.Convolution(data = pool_1, kernel = c(5, 5), num_filter = 50) | |
> tanh_2 <- mx.symbol.Activation(data = conv_2, act_type = "tanh") | |
> #tanh_2 <- mx.symbol.SoftmaxActivation(data = conv_2) | |
> pool_2 <- mx.symbol.Pooling(data=tanh_2, pool_type = "max", kernel = c(2, 2), stride = c(2, 2)) | |
> # 1st fully connected layer | |
> flatten <- mx.symbol.Flatten(data = pool_2) | |
> fc_1 <- mx.symbol.FullyConnected(data = flatten, num_hidden = 500) | |
> tanh_3 <- mx.symbol.Activation(data = fc_1, act_type = "tanh") | |
> # 2nd fully connected layer | |
> fc_2 <- mx.symbol.FullyConnected(data = tanh_3, num_hidden = 6) | |
> # Output. Softmax output since we'd like to get some probabilities. | |
> NN_model <- mx.symbol.SoftmaxOutput(data = fc_2, multi.output = TRUE) | |
> # Set seed for reproducibility | |
> mx.set.seed(100) | |
> | |
> # Device used. CPU in my case. | |
> devices <- mx.cpu() | |
> | |
> model <- mx.model.FeedForward.create(NN_model, | |
+ X = train_array, | |
+ y = train_y, | |
+ ctx = devices, | |
+ num.round = 380, | |
+ array.batch.size = 76, | |
+ learning.rate = 0.01, | |
+ momentum = 0.9, | |
+ eval.metric = mx.metric.accuracy, | |
+ epoch.end.callback = mx.callback.log.train.metric(100)) | |
Error in mx.io.internal.arrayiter(as.array(data), as.array(label), unif.rnds, : | |
basic_string::resize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment