项目作者: balovbohdan

项目描述 :
Feedforward Artificial Neural Network Library
高级语言: TypeScript
项目地址: git://github.com/balovbohdan/fwd-ann.git
创建时间: 2019-10-23T13:53:03Z
项目社区:https://github.com/balovbohdan/fwd-ann

开源协议:MIT License

下载


About

fwd-ann is a Feedforward Artificial Neural Network Library developed with TypeScript.
This project was started as experiment to explore TypeScript abilities to be used in
data processing tasks. You can use this library for experimental data processing on Node.js
server or in a browser. Very early version of this library was successfully used in AMAKids
company as core for building browser games results analyzer platform.

Installation

  1. npm i --save fwd-ann

Examples

Go to the src/examples to explore examples. To run example run ts-node <example-name>
your console. Better way to understand how this library works is to explore these examples.
Another good way to understand this library — explore src library and create
small projects. Feel free to create anything you want using this library!

Below you can find short introduction to the API. It will help you to get
started with fwd-ann.

API

LayerType

This enum represents possible types of ANN’s layers. There are three possible types:

  • INPUT
  • HIDDEN
  • OUTPUT

These types are used to create ANN’s instance with aim architecture.

activationFuncs

Activation function determines how signals will be modified in neurons. There are lots of
available activation functions:

  • Logistic
  • UnitLinear
  • BinaryStep
  • Areasinus
  • …and so on

Signals

Signals class represents numbers vector that can be used as input for
ANN (Artificial Neural Network). To create Signals you simply should pass numbers array
to the Signals.create static method:

  1. import { Signals } from 'fwd-ann';
  2. const signals = new Signals([1, 0, 0, 1]);

You can also create Signals by passing Matrix to Signal‘s class constructor. Matrix is a
special class that you can import from
matrix-calculus library.

  1. import { Signals } from 'fwd-ann';
  2. import { SingleColMatrixFactory } from 'matrix-calculus/factories';
  3. const signalsMatrix = SingleColMatrixFactory.create([1, 0, 0, 1]);
  4. const signals = new Signals(signalsMatrix);

You can pass second (optional) parameter to the Signals.create or Signals‘s constructor that
represents names for every passed signal. In some cases it is useful to have signals’ names.

ANN, createANN

To create ANN object you can use ANN class or createANN utility. Prefer second one.
ANN instance represents Artificial Neural Network that can be taught by Teacher
and used to process some input Signals and respond with some output Signals.

  1. import createANN, { LayerType, activationFuncs } from 'fwd-ann';
  2. const { ReLU } = activationFuncs;
  3. const ann = createANN(
  4. {
  5. id: 'ExampleANN',
  6. layersData: [
  7. {
  8. type: LayerType.INPUT,
  9. unitsData: [{
  10. qty: 6,
  11. ActivationFunction: ReLU,
  12. }],
  13. },
  14. {
  15. type: LayerType.HIDDEN,
  16. unitsData: [{
  17. qty: 7,
  18. ActivationFunction: ReLU,
  19. }],
  20. },
  21. {
  22. type: LayerType.OUTPUT,
  23. unitsData: [{
  24. qty: 1,
  25. ActivationFunction: ReLU,
  26. }],
  27. },
  28. ],
  29. },
  30. {
  31. learningSpeed: .01,
  32. },
  33. );

First parameter represents data of the Neural Network. Second parameter (optional) represents
parameters such as learningSpeed.

Teacher

The Teacher is that core thing that teaches your Neural Network to perform
some actions you need. Teacher‘s API is vary simple and allows you concentrate on
data and behavior but not on the teaching process implementation.

  1. import createANN, { Teacher } from 'fwd-ann';
  2. const ann = createANN({
  3. id: 'ExampleANN',
  4. layersData: [/*...*/],
  5. });
  6. Teacher.teach({
  7. ann,
  8. sets: [/*...*/],
  9. }).then(({ ann, log }) => {/*...*/});

Do notice! Teacher mutates your ann instance.

GitHub repository

https://github.com/balovbohdan/fwd-ann

Contributing

Pull requests are welcome. You can use this code freely for
your own projects and/or experiments. If you have some questions or proposals
feel free to message me.

License

MIT