Giter Site home page Giter Site logo

matlab-neural-network's Introduction

Matlab Neural Network

A simple and modular way of implementing a neural network with Matlab.

Layers

  • FullyConnectedLayer(input_shape, output_shape)
  • ConvolutionalLayer(input_shape, kernel_shape, layer_depth)
  • MaxPoolLayer(input_shape, kernel_shape)
  • FlattenLayer(input_shape)
  • ActivationLayer(input_shape, activation)
  • DropoutLayer(input_shape, drop_rate)

Activations

  • Sigmoid ('sigmoid')
  • Hyperbolic Tangant ('tanh')
  • Rectified Linear Unit ('relu')
  • Leaky Rectified Linear Unit ('leaky_relu')
  • Linear ('linear')
  • Exponential ('exp')
  • Softplus ('softplus')
  • Softsign ('softsign')

Losses

  • Mean Squared Error ('mse')
  • Mean Squared Logarithmic Error ('msle')
  • Mean Absolute Error ('mae')
  • Negative Logarithmic Likelihood ('neg_log_likelihood')
  • Cross Entropy ('cross_entropy')

Example

Simple neural network applied to the XOR problem. See all examples here.

% IO data
input = [0 0 ; 0 1 ; 1 0 ; 1 1];
output = [0 ; 1 ; 1 ; 0];

% reshape data for neural network (sample dimension last)
input = reshape(rot90(input), [1,2, 4]);
output = reshape(rot90(output), [1,1, 4]);

% create a 3-layer neural network
net = Network({
    FullyConnectedLayer([1 2], [1 3])
    ActivationLayer([1 3], Activation("tanh"))
    FullyConnectedLayer([1 3], [1 1])
    ActivationLayer([1 1], Activation("tanh"))
});

% set cost function and learning_rate
net.build(Loss('mse'), 0.2)

% train on 1000 iterations
net.fit(input, output, 1000);

% test network
net.predict(input)

Save / Load Network

% save network
net.save('network.mat');

% load network
net = Network.load('network.mat');

matlab-neural-network's People

Contributors

omaraflak 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.