You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/11/13 07:32:36 UTC
[GitHub] shivonkar commented on issue #8575: mxnet multicore on LInux in R
shivonkar commented on issue #8575: mxnet multicore on LInux in R
URL: https://github.com/apache/incubator-mxnet/issues/8575#issuecomment-343836005
The working test code is here and error is attached
g_working_directory <- ifelse(Sys.info()['sysname'] == "Windows", "D:/INFY_BACKUP/Projects/Analytics/Practice/R/Prospects/amex/analytics/rscript", "/data/data/analytics/rscript/")[[1]]
setwd(g_working_directory);
if(Sys.info()['sysname'] == "Linux") .libPaths(c("/data/data/analytics/packages/", .libPaths()))
library(logging); library(mxnet)
#Adding logger
addHandler(handler = writeToFile, file = "log.txt"); basicConfig(level = "INFO")
# Get data for training
train.x <- data.matrix(airquality[,c('Ozone', 'Solar.R', 'Wind')])
train.x[is.na(train.x)] <- 0
train.y <- as.numeric(ifelse(airquality[,c('Temp')] < 70, 0, 1))
# Prepare the layers
data <- mx.symbol.Variable("data")
fc1 <- mx.symbol.FullyConnected(data, name="fc1", num_hidden=3 )
act1 <- mx.symbol.Activation(fc1, name="relu1", act_type="relu") # "relu" tanh
fc2 <- mx.symbol.FullyConnected(act1, name="fc2", num_hidden=3 )
act2 <- mx.symbol.Activation(fc2, name="relu2", act_type="relu")
fc3 <- mx.symbol.FullyConnected(act2, name="fc3", num_hidden=2)
softmax <- mx.symbol.SoftmaxOutput(fc3, name="sm")
# Get all available CPUs. http://mxnet.io/how_to/env_var.html
core <- as.integer(min(7, parallel::detectCores()))
cpu_devices = lapply(1:core, function(i) {mx.cpu(i)})
loginfo(paste0('Available cores are: ', parallel::detectCores(), ', and using ', core))
l_list_tuned_param <- list(act_type="relu", num.round=10, array.batch.size=8, learning.rate=0.07, momentum=0.9, initializer=0.01, optimizer ="sgd")
# Building model
tryCatch(fit_dl <- mx.model.FeedForward.create(softmax, X=data.matrix(train.x), y = as.numeric(train.y), ctx=cpu_devices, num.round=l_list_tuned_param[['num.round']], array.batch.size=l_list_tuned_param[['array.batch.size']], learning.rate=l_list_tuned_param[['learning.rate']], momentum=l_list_tuned_param[['momentum']], initializer=mx.init.uniform(l_list_tuned_param[['initializer']]), optimizer = l_list_tuned_param[['optimizer']],eval.metric=mx.metric.accuracy, array.layout = "rowmajor"), error = function(cond){logerror(cond); quit(save = "no", status = 0, runLast = F)})
loginfo("Building complete")
----------------------------------------------------------------
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