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)
  • 相关阅读:
    折半插入排序-ACM题
    xcode 常用快捷键
    折半插入排序-算法
    插入排序
    HTML5 data-* 自定义属性
    vertical-align属性baseline(转)
    CSS 基础点
    解决-word里无论怎么改变字体颜色,字体总是红色的
    css属性前加*号的作用
    php 函数的嵌套
  • 原文地址:https://www.cnblogs.com/qianheng/p/10850162.html
Copyright © 2011-2022 走看看