Giter Site home page Giter Site logo

lulzzz / dlmatframework-1 Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 2.0 441.73 MB

Implementation of Deeplearning library based on my book https://leonardoaraujosantos.gitbooks.io/artificial-inteligence/content/

License: MIT License

MATLAB 1.40% Shell 5.53% Python 0.99% Jupyter Notebook 90.56% CMake 0.01% C++ 1.49% QMake 0.01% C 0.01% C# 0.02%

dlmatframework-1's Introduction

Deep Learning Matlab Framework

Introduction

Implementation of Deeplearning library based on my books:

Example from command line

%% Test the creation/training of a 2 layer 2 class(not binary) classifier
clear all;
% Reset random number generator state, this is needed in order to make the
% weight initialization go work
rng(0,'v5uniform');

%% Load data (MNIST)
load mnist_oficial;
data = Dataset(input_train, output_train_labels,1,784,1,1);
data.AddValidation(input_test,output_test_labels,1,784,1,1);

%% Create network
layers = LayerContainer();    
layers <= struct('name','ImageIn','type','input','rows',1,'cols',784,'depth',1, 'batchsize',1);
layers <= struct('name','FC_1','type','fc', 'num_output',50);
layers <= struct('name','Relu_1','type','relu');
layers <= struct('name','FC_2','type','fc','num_output',data.GetNumClasses());
layers <= struct('name','Softmax','type','softmax');

% Create DeepLearningModel instance
net = DeepLearningModel(layers, LossFactory.GetLoss('cross_entropy'));

%% Create solver and train
solver = Solver(net, data, 'sgd',containers.Map({'learning_rate'}, {0.01}));
solver.SetBatchSize(64);
solver.SetEpochs(100);
solver.Train();

%% Test
figure(2);
batchValidation = data.GetValidationBatch(10);
display_MNIST_Data(reshape_row_major(batchValidation.X,[10,784]));
title('Images on validation');
errorCount = 0;

% Predict the batch
scores = net.Predict(batchValidation.X);
[~, idxScoresMax] = max(scores,[],2);
[~, idxCorrect] = max(batchValidation.Y,[],2);
% Subtract one (First class )
idxScoresMax = idxScoresMax - 1;
idxCorrect = idxCorrect - 1;

% Compare scores with target
for idx=1:10    
    if idxScoresMax(idx) ~= idxCorrect(idx)
        errorCount = errorCount + 1;
        fprintf('Predicted %d and should be %d\n',idxScoresMax(idx),idxCorrect(idx));
    end    
end
errorPercentage = (errorCount*100) / 10;
fprintf('Accuracy is %d percent \n',round((100-errorPercentage)));

plot(solver.GetLossHistory)

Objectives

The idea is to create a library as readable as possible while maintaning usability by giving the following features

  • C/C++ code generation support
  • Support for low-end platforms like raspbery PI
  • Allows graphical representation of models on simulink
  • GPU implementation on both CUDA and OpenCL
  • Usage of matlab distributed features for scaling and performance

Tutorials or references

All documentation will be available through my books or youtube channel. I will add tutorials as needed.

dlmatframework-1's People

Contributors

burton2000 avatar dpackwood avatar leonardoaraujosantos avatar

Watchers

 avatar  avatar

Forkers

play3577 tplink32

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.