npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

synaptic-population

v1.3.0

Published

A population of neural networks built over synapticjs using evolution process instead of backpropagation

Downloads

9

Readme

js-synaptic-population

A population of neural networks built over (synapticjs)[https://caza.la/synaptic/] using evolution process instead of backpropagation

Installation

npm i synaptic-population

Usage

import Population from 'synaptic-population';        // es6 import

or

const Population = require('synaptic-population');   // classic nodejs require
// Create a population with some optionals rules
const population = new Population({
  demography : 10,            // Number of brains in the population. Default 10.
  eliteDemography : 4,        // Number of brains that will survive natural selection on each generation. Default 4.
  extinctionFitness : null,   // If all brains in a generation get a lower score that this parameter, then all the population is reset. Default null.
  inputs : 1,                 // Number of inputs required to activate brains. Default 2.
  outputs : 1,                // Number of outputs returned from the brains. Default 1.
  hiddenLayers : [8],         // Array of numbers representing the hidden layers neurons. Default [8] (one hidden layer of 8 neurons)
  mutateRate : 0.2,            // Mutation rate from 0 (no mutation) to 1 (full mutation) applied when evolving
  trainedPop: null            // Retrieve a previously exported population (see method toJSON())
});

// Activate brains
population.activateBrain(brainID, inputs);

// Set fitness of brains
population.setBrainFitness(brainID, fitness);

// Evolve
population.evolve();

// And do it again until your population does what you want them to do !

See x

API

Properties

  • brains : array READ-ONLY // Array of neural networks.
  • demography : int READ-ONLY, // Number of brains in the population. Default 10 .
  • eliteDemography : int READ-ONLY, // Number of brains that will survive natural selection on each generation. Default 4.
  • extinctionFitness : number or null READ-ONLY, // If all brains in a generation get a lower score that this parameter, then all the population is reset. Default null.
  • generation : int READ-ONLY // Number of generation that occurred into the population.
  • hiddenLayers : array of int READ-ONLY, // Array of numbers representing the hidden layers neurons. Default [8] (one hidden layer of 8 neurons)
  • inputs : int READ-ONLY, // Number of inputs required to activate brains. Default 1.
  • mutateRate : float [0-1] // Mutation rate from 0 (no mutation) to 1 (all the children mutates) applied when evolving. Default 0.2.
  • mutateFactor : int // The degree of mutation applied when mutating a child. Default 3.
  • outputs : int READ-ONLY, // Number of outputs returned from the brains. Default 1.
  • trainedPop: JSON object READ-ONLY // retrieve a previously exported population (see method toJSON()). Default null.

Methods

// Create a population with some optionals rules

  • constructor({

    • demography = 10, // Number of brains in the population. Default 10.
    • eliteDemography = 4, // Number of brains that will survive natural selection on each generation. Default 4.
    • extinctionFitness = null, // If all brains in a generation get a lower score that this parameter, then all the population is reset. Default null.
    • inputs = 2, // Number of inputs required to activate brains. Default 2.
    • outputs = 1, // Number of outputs returned from the brains. Default 1.
    • hiddenLayers = [8], // Array of numbers representing the hidden layers neurons. Default [8] (one hidden layer of 8 neurons)
    • mutateRate = 0.2, // Mutation rate from 0 (no mutation) to 1 (full mutation) applied when evolving. Default 0.2
    • trainedPop = null // Retrieve a previously exported population (see method toJSON()). Default null

    });

// Activate a brain neurons with inputs array

  • activateBrain(id, inputs) id : the brain (individual) ID in your population inputs : an inputs array for activating neurons

// Set the fitness of a brain

  • setBrainFitness(id, fitness) id : the brain (individual) ID in your population fitness : the score to assign to the brain

// Returns a brain given its ID

  • getBrain(id) id : the brain (individual) ID in your population

// Keep the bests, kill the rest and replace them with children of the bests

  • evolve()

// Reset the population to generation 0, all training is lost

  • reset()

// Export the current population into JSON object

  • toJSON()