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/07/31 08:15:37 UTC

[GitHub] janejane11 opened a new issue #7262: use R3.3.0 and im2rec.py to run cnn and always failed

janejane11 opened a new issue #7262: use R3.3.0 and im2rec.py to run cnn and always failed
URL: https://github.com/apache/incubator-mxnet/issues/7262
 
 
   this is my code below,I have run it many times,but it always failed and my computer stopped working, I check my memories,my memories are 8GB
   it failed because my memories are not enough? or some other problems?
   please answer me how can I run it successfully
   
   library(mxnet)
   
   train = mx.io.ImageRecordIter(
     path.imglist="C:/train1/train1.lst",
     path.imgrec="C:/train1/train1.rec",
     batch.size=4,
     #round.batch=TRUE,
     data.shape=c(224,224,1),
     preprocess.threads=1
   )
   
   test = mx.io.ImageRecordIter(
     path.imglist="C:/test1/test1.lst",
     path.imgrec="C:/test1/test1.rec",
     batch.size=4,
     data.shape=c(224,224,1),
     #round.batch=FALSE,
     preprocess.threads=1
   )
   
   
   data <- mx.symbol.Variable('data')
   
   conv1 <- mx.symbol.Convolution(data=data, kernel=c(5,5), num_filter=20)
   tanh1 <- mx.symbol.Activation(data=conv1, act_type="tanh")
   pool1 <- mx.symbol.Pooling(data=tanh1, pool_type="max",kernel=c(2,2), stride=c(2,2))
   
   conv2 <- mx.symbol.Convolution(data=pool1, kernel=c(5,5), num_filter=50)
   
   tanh2 <- mx.symbol.Activation(data=conv2, act_type="tanh")
   pool2 <- mx.symbol.Pooling(data=tanh2, pool_type="max",kernel=c(2,2), stride=c(2,2))
   
   flatten <- mx.symbol.Flatten(data=pool2)
   fc1 <- mx.symbol.FullyConnected(data=flatten, num_hidden=500)
   tanh3 <- mx.symbol.Activation(data=fc1, act_type="tanh")
   
   fc2 <- mx.symbol.FullyConnected(data=tanh3, num_hidden=10)
   
   
   lenet <- mx.symbol.SoftmaxOutput(data=fc2)
   
   mx.set.seed(0)
   
   model <- mx.model.FeedForward.create(lenet, X=train, y=train.y,
   ctx=mx.cpu(), num.round=5, array.batch.size=1,
   learning.rate=0.05, momentum=0.9, wd=0.00001,
   eval.metric=mx.metric.accuracy,
   epoch.end.callback=mx.callback.log.train.metric(100))
   
   
   preds <- predict(model, test.array)
   
   pred.label <- max.col(t(preds)) - 1
   
   table(test_org[,1],pred.label)
   
   sum(diag(table(test_org[,1],pred.label)))/1000
   --------------------------------------------------------------------end
   
   
   
 
----------------------------------------------------------------
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