apache mxnet 深度学习神经网络小试

http://mxnet.incubator.apache.org/versions/master/install/index.html?platform=Windows&language=R&processor=CPU

1 cran <- getOption("repos")
2 cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/"
3 options(repos = cran)
4 install.packages("mxnet")

安装之前需要指定repository

一起安装的包

package ‘brew’ successfully unpacked and MD5 sums checked
package ‘hms’ successfully unpacked and MD5 sums checked
package ‘clipr’ successfully unpacked and MD5 sums checked
package ‘XML’ successfully unpacked and MD5 sums checked
package ‘Rook’ successfully unpacked and MD5 sums checked
package ‘downloader’ successfully unpacked and MD5 sums checked
package ‘igraph’ successfully unpacked and MD5 sums checked
package ‘influenceR’ successfully unpacked and MD5 sums checked
package ‘readr’ successfully unpacked and MD5 sums checked
package ‘rgexf’ successfully unpacked and MD5 sums checked
package ‘DiagrammeR’ successfully unpacked and MD5 sums checked
package ‘visNetwork’ successfully unpacked and MD5 sums checked
package ‘mxnet’ successfully unpacked and MD5 sums checked

额外的依赖

To run MXNet you also should have OpenCV and OpenBLAS installed.

第一步:数据准备

1 set.seed(0)
2 #随机分配训练集和测试集
3 train.ind = sample(1:nrow(inp), size=ceiling(0.7*nrow(inp)))
4 
5 train.x = data.matrix(inp[train.ind,NIRDATA])
6 train.y = inp[train.ind,NIC]
7 test.x = data.matrix(inp[-train.ind,NIRDATA])
8 test.y = inp[-train.ind,NIC]

第二步:创建网络并训练

1 mx.set.seed(0)
2 
3 model <- mx.mlp(train.x, train.y, hidden_node=c(7), out_node=1, out_activation="rmse",
4                 num.round=2000, array.batch.size=15, learning.rate=0.05, momentum=0.9,
5                 eval.metric=mx.metric.rmse)

hidden_node接受向量,c(100,50)代表两层隐含层,分别具有100和50个节点

out_node输出层

eval.metric=mx.metric.rmse
评估方法,rmse 标准差
评估测试集
predict(model,test.x)->prd

plot(prd,test.y)

 

转载于:https://www.cnblogs.com/qianheng/p/10850162.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值