Fantastico modulo comunitario

sinapticoStato di costruzione Unisciti alla chat su https://synapticjs.slack.com

Importante: Synaptic 2.x è attualmente in fase di discussione Sentiti libero di partecipare

Synaptic è una libreria di rete neurale javascript per node.js e il browser , il suo algoritmo generalizzato è privo di architettura, quindi puoi creare e addestrare praticamente qualsiasi tipo di architettura di rete neurale di primo ordine o anche di secondo ordine .

Questa libreria include alcune architetture integrate come percettroni multistrato , reti di memoria a lungo termine multistrato (LSTM), macchine a stato liquido o reti Hopfield e un trainer in grado di addestrare qualsiasi rete, che include attività integrate/addestramento Come risolvere uno XOR, completando un'attività Distracted Sequence Recall o un Embedded Reber Grammar test, in modo da poter facilmente testare e confrontare le prestazioni di diverse architetture.

L'algoritmo implementato da questa libreria è stato preso dall'articolo di Derek D. Monner:

Un algoritmo di addestramento simile a LSTM generalizzato per reti neurali ricorrenti di secondo ordine

Ci sono riferimenti alle equazioni in quel documento commentate attraverso il codice sorgente.

introduzione

Se non hai alcuna conoscenza preliminare delle reti neurali, dovresti iniziare leggendo questa guida .

Se vuoi un esempio pratico su come fornire dati a una rete neurale, dai un'occhiata a questo articolo .

Potresti anche voler dare un'occhiata a questo articolo .

Demo

Il codice sorgente di queste demo può essere trovato in questo ramo .

Iniziare

Per provare gli esempi, controlla il ramo gh-pages .

git checkout gh-pages

Altre lingue

Questo README è disponibile anche in altre lingue.

Panoramica

Installation

Nel nodo

Puoi installare synaptic con npm :

1
npm install synaptic --save
Nel navigatore

Puoi installare synaptic con bower :

1
bower install synaptic

Oppure puoi semplicemente utilizzare il collegamento CDN, gentilmente fornito da CDNjs

1
<script src="https://cdnjs.cloudflare.com/ajax/libs/synaptic/1.1.4/synaptic.js"></script>

Usage

1 2 3 4 5 6
var synaptic = require('synaptic'); // this line is not needed in the browser var Neuron = synaptic.Neuron, Layer = synaptic.Layer, Network = synaptic.Network, Trainer = synaptic.Trainer, Architect = synaptic.Architect;

Ora puoi iniziare a creare reti, addestrarle o utilizzare reti integrate da Architect .

Examples

Perceptron

Ecco come puoi creare un semplice perceptron :

perceptron.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
function Perceptron(input, hidden, output) { // create the layers var inputLayer = new Layer(input); var hiddenLayer = new Layer(hidden); var outputLayer = new Layer(output); // connect the layers inputLayer.project(hiddenLayer); hiddenLayer.project(outputLayer); // set the layers this.set({ input: inputLayer, hidden: [hiddenLayer], output: outputLayer }); } // extend the prototype chain Perceptron.prototype = new Network(); Perceptron.prototype.constructor = Perceptron;

Ora puoi testare la tua nuova rete creando un trainer e insegnando al perceptron a imparare uno XOR

1 2 3 4 5 6 7 8 9
var myPerceptron = new Perceptron(2,3,1); var myTrainer = new Trainer(myPerceptron); myTrainer.XOR(); // { error: 0.004998819355993572, iterations: 21871, time: 356 } myPerceptron.activate([0,0]); // 0.0268581547421616 myPerceptron.activate([1,0]); // 0.9829673642853368 myPerceptron.activate([0,1]); // 0.9831714267395621 myPerceptron.activate([1,1]); // 0.02128894618097928
Memoria lunga a breve termine

Ecco come puoi creare una semplice rete di memoria a lungo e breve termine con porte di ingresso, porte dimenticate, porte di uscita e connessioni spioncino:

memoria lunga a breve termine

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
function LSTM(input, blocks, output) { // create the layers var inputLayer = new Layer(input); var inputGate = new Layer(blocks); var forgetGate = new Layer(blocks); var memoryCell = new Layer(blocks); var outputGate = new Layer(blocks); var outputLayer = new Layer(output); // connections from input layer var input = inputLayer.project(memoryCell); inputLayer.project(inputGate); inputLayer.project(forgetGate); inputLayer.project(outputGate); // connections from memory cell var output = memoryCell.project(outputLayer); // self-connection var self = memoryCell.project(memoryCell); // peepholes memoryCell.project(inputGate); memoryCell.project(forgetGate); memoryCell.project(outputGate); // gates inputGate.gate(input, Layer.gateType.INPUT); forgetGate.gate(self, Layer.gateType.ONE_TO_ONE); outputGate.gate(output, Layer.gateType.OUTPUT); // input to output direct connection inputLayer.project(outputLayer); // set the layers of the neural network this.set({ input: inputLayer, hidden: [inputGate, forgetGate, memoryCell, outputGate], output: outputLayer }); } // extend the prototype chain LSTM.prototype = new Network(); LSTM.prototype.constructor = LSTM;

Questi sono esempi a scopo esplicativo, l' architetto include già architetture di rete Multilayer Perceptrons e Multilayer LSTM.

Contribuire

Synaptic è un progetto Open Source che ha avuto inizio a Buenos Aires, in Argentina. Chiunque nel mondo è invitato a contribuire allo sviluppo del progetto.

Se vuoi contribuire, sentiti libero di inviare PR, assicurati di eseguire npm run test e npm run build prima di inviarlo.In questo modo eseguirai tutte le specifiche di test e compilerai i file di distribuzione web.

Supporto

Se ti piace questo progetto e vuoi mostrare il tuo supporto, puoi offrirmi una birra con i magici soldi di internet :

1 2 3 4
BTC: 16ePagGBbHfm2d6esjMXcUBTNgqpnLWNeK ETH: 0xa423bfe9db2dc125dd3b56f215e09658491cc556 LTC: LeeemeZj6YL6pkTTtEGHFD6idDxHBF2HXa XMR: 46WNbmwXpYxiBpkbHjAgjC65cyzAxtaaBQjcGpAZquhBKw2r8NtPQniEgMJcwFMCZzSBrEJtmPsTR54MoGBDbjTi2W1XmgM

<3