Coder Social home page Coder Social logo

neuralnetwork.js's Introduction

NeuralNetwork.js

Simple neural network implemented from scratch in JavaScript

Implementation

The neural network is implemented in the NeuralNetwork class. The class is initialized with the number of input nodes, hidden nodes, and output nodes. The class has a train method that takes in an input array and a target array and adjusts the weights and biases of the network accordingly. The class also has a predict method that takes in an input array and returns the output of the network.

The network uses the sigmoid activation function and the mean squared error loss function.

Example

const nn = new NeuralNetwork(2, 2, 1);

nn.train([1, 0], [1]);
nn.train([0, 1], [1]);
nn.train([1, 1], [0]);
nn.train([0, 0], [0]);

console.log(nn.predict([1, 0])); // 0.999
console.log(nn.predict([0, 1])); // 0.999
console.log(nn.predict([1, 1])); // 0.001
console.log(nn.predict([0, 0])); // 0.001

License

This project is licensed under the MIT License - see the LICENSE file for details

neuralnetwork.js's People

Contributors

washingtonyandun avatar

Watchers

 avatar  avatar

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.