Code Monkey home page Code Monkey logo

neural-network-r's Introduction

Neural-Network-R

An Artificial Neural Network (ANN) is created and trained on the pima-indians-diabetes dataset using R. Rather than doing backpropagation one instance at a time, the weight updates are calculated for all training instances at once, and summing these to calculate the net change.
For a given layer in the ANN, a matrix W is used to hold the values of all weights, where W(i,j) is the weight of the edge going from input node i to output node j.

The following functions are implemented in the code:

  • The function sigmoid calculates the sigmoid [f(x) = 1/(1+e^-x)] of an input vector x. The function sigmoid_derivative calculates the derivative of the sigmoid function with respect to a matrix x.
  • The calculate_loss function takes the predicted values and actual values as input and computes the loss of predictions.
  • The calculate_activations function is used to calculate the activation vector for a given node, given the input matrix of activations from the prior layer, and the weight matrix. The input is a matrix, where each row corresponds to one training instance and each column corresponds to the activation of a node in the previous layer. The output is a vector, where each item in the vector represents the outputs for one training instance.
  • There are two kinds of gradients calculated to perform back propagation, besides the gradient for the activation function that's already calculated in sigmoid_derivative(). In calculate_dCdw(), the derivative of the cost with respect to a weight matrix is calculated. In calculate_dCdf(), the derivative of the cost with respect to activation values, calculated by calculate_activations() is computed.
  • The function neuralnet utilizes all the above mentioned function to train the neural network.

neural-network-r's People

Contributors

rohitnair11 avatar

Watchers

 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.