zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    正则表达式 UBB 实例
    ThinkSNS1.6 群组邀请好友 通知页面,出现同意,忽略功能
    netbeans 自己常用的快捷键
    Windows下安装PEAR, PHPUnit成功
    PHP XML 的 DOMDocument 读取功能
    PHP XML 的 DOMDocument 创建内容
    使用 JSON 进行数据传输
    Jquery操作select
    去除VMWare Beep(VMWare 声音|嘟)
    一步步创建 边栏 Gadget(二)
  • 原文地址:https://www.cnblogs.com/qianheng/p/10850162.html
Copyright © 2011-2022 走看看