Giter Club home page Giter Club logo

tmps's Introduction

Author: Morari Gheorghe

Topic:

Practical use of behavioral design patterns.

Domain:

Artificial intelligence and neural networks.

LAB3:

Iterator

layer_iterator.h LayerIterator class, used for the functionality of traversing the neural network layers without exposing its structure.

image

Because i used the C++ language, which already has syntax for iterators, i just wrote the LayerIterator as a custom iterator for the Network class, which means that i can use C++ iterator specific syntax:

image

Usage of the LayerIterator within the Network class

image

Motivation:

Because of the non-linear nature of the neural network implementation of layers, no layer has a direct connection to the next layer, which means that if we need to traverse layers, we need to query one of the nodes inside the layer, to get the next layer. This iterator does this for us, and using the begin and end function, we can traverse all the layers in all neural networks with ease.

Conclussion:

Using the Iterator design pattern we have a way to access all the layers of the neural network with ease, in the case i used, i only printed the weights of the neurons, but because i have a pointer to those neurons, i can virtually do anything with them, where previously i couldn't.

LAB2:

Decorator:

dnetwork.h DNetwork class(decorator network), used for the added functionality of printing the neural network's layers without modifying the base class.

image

Usage: (Network does not have a print_all_layers() function)

image

Facade:

fsoftmax.h softmax_layer function (facade for softmax), used for simplifying the softmax interface.

image

Usage: Adds the ability to call the softmax singleton to easily apply the softmax transformation for an array of numbers.

image

Composite:

link.h Link class, used as a composite for neurons, by calling all children' on_send(), or on_receive() functions.

image

Usage: Call the same function with the same arguments for multiple neurons in a layer using a link.

image

LAB1:

To instantiate a neuron, we can use:

  1. NeuronBuilder - Builder pattern.

image

  1. IObject::copy() virtual method - Prototype pattern.

image

To instantiate a link, we can use:

  1. IObject::copy() virtual method - Prototype pattern.

image

To instantiate a Softmax, we can use:

  1. Softmax::getInstance() static method - Singleton pattern.

image

Results:

  1. Easy network creation, thanks to builder pattern:

image

  1. Easy softmax usage, thanks to singleton pattern:

image

  1. Easy copying of neurons and links, thanks to the prototype pattern.

image

tmps's People

Contributors

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