Coder Social home page Coder Social logo

learningdl's Introduction

learningDL

demo性质的mnist数据集手写数字识别的神经网络, 不借助外部库全部手动搭建.

基本属于一个读书笔记, 看的这本书: Alt: 深度学习入门

简单的4层网络(两个隐含层)

  • 网络数量: 可自定义, 见 networkConfig.js
  • 激活函数: ReLU
  • 求偏导方式: 反向传播
  • 损失函数: SoftmaxWithLoss

19.6.8 更新: 之前的代码都是有问题的, 真正跑通是在这次更新

文件说明

  • network.js: 网络的实现
  • networkConfig.js 网络的配置
  • weights.js 保存整个网络的所有权重
  • training.js 用来训练网络
  • test.js 用来测试网络训练结果
  • sumLoss.json 用来观察最后3000(training.js中配置)个损失函数值

使用方式

//初始化
npm install
//训练, 注意: 从零开始的话, 注释掉 'ws' 项, 即不引入初始权重
npm start
//测试训练结果, 记得不要注释 'ws' 项, 即导入已有权重
npm test
//应用网络
把 test.js 里的代码手动copy出来稍微改一下(笑)

learningdl's People

Contributors

mxxxxxs avatar

Stargazers

 avatar  avatar

learningdl's Issues

Not quite readable

training.js 应该写了BP在里面吧?怎么找不出来呢? 建议把变量名写全一点,不然没法读诶.

for (let j = 0; j < trainingTime; j++) {
for (let i = 0; i < trainingSet.length; i++) {
  let input = trainingSet[i].input
  let target = trainingSet[i].output
    const layersOutput = layers.reduce((preLayer, curLayer) => {
       curLayer.input(preLayer)
       return curLayer.forward()
    }, [input])

    finalLayer.input(layersOutput, target)
    const backward0 = finalLayer.backward()
  
    if (sumLoss.length > 3000)
    sumLoss.shift()
    sumLoss.push(finalLayer.sumLoss())

    layers.reverse().reduce((preD, curLayer) => {
      curLayer.update(preD)
      return curLayer.backward(preD)
    }, backward0)
    layers.reverse()
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.