Skip to main content
This release is 243 versions behind 0.166.0 — the latest version of @stsoftware/neat-ai. Jump to latest

Built and signed on GitHub Actions

NEAT Neural Network. This project is a unique implementation of a neural network based on the NEAT (NeuroEvolution of Augmenting Topologies) algorithm, written in DenoJS using TypeScript.

This package works with Deno
This package works with Deno
JSR Score
94%
Published
11 months ago (0.70.1)
class Creature
implements CreatureInternal

Constructors

new
Creature(
input: number,
output: number,
options?: { lazyInitialization?: boolean; layers?: { squash?: string; count: number; }[]; },
)

Properties

private
cacheFrom: Map<number, Synapse[]>
private
cacheSelf: Map<number, Synapse[]>
private
cacheTo: Map<number, Synapse[]>
neurons: Neuron[]
abstract
score: number
readonly
state: CreatureState
synapses: Synapse[]
abstract
tags: TagInterface[]
abstract
uuid: string

Methods

activate(
input: number[],
feedbackLoop?: boolean,
): number[]

Activates the creature without calculating traces and such

activateAndTrace(
input: number[],
feedbackLoop?: boolean,
): number[]

Activates the creature

private
addBackConn(focusList?: number[]): void
addConnection(
focusList?: number[],
options?: { weightScale: number; },
): void
addNeuron(focusList?: number[]): void
private
addSelfCon(focusList?: number[]): void
applyLearnings(config: BackPropagationConfig): boolean
clearCache(
from?,
to?,
): void
clearState(): void

Clear the context of the creature

compact(): Creature | undefined

Compact the creature.

connect(
from: number,
to: number,
weight: number,
type?:
"positive"
| "negative"
| "condition"
,
): Synapse

Connects the from neuron to the to node

disconnect(
from: number,
to: number,
): void

Disconnects the from neuron from the to node

dispose(): void
private
evaluateData(
json: { input: number[]; output: number[]; }[],
cost: CostInterface,
feedbackLoop: boolean,
): { error: number; count: number; }
evaluateDir(
dataDir: string,
cost: CostInterface,
feedbackLoop: boolean,
): { error: number; }

Tests a set and returns the error and elapsed time

evolveDataSet(
dataSet: DataRecordInterface[],
options: NeatOptions,
): Promise<{ error: number; score: number; time: number; }>

Evolves the creature to reach a lower error on a dataset

evolveDir(
dataSetDir: string,
options: NeatOptions,
): Promise<{ error: number; score: number; time: number; }>

Evolves the creature to reach a lower error on a dataset

Convert the creature to a json object

fix(): void

Fix the creature

getSynapse(
from: number,
to: number,
): Synapse | null
inFocus(
index: number,
focusList?: number[],
checked?: Set<number>,
): boolean
private
initialize(options: { layers?: { squash?: string; count: number; }[]; }): void
private
insertNeuron(neuron: Neuron): void
internalJSON(): CreatureInternal
inwardConnections(toIndx: number): Synapse[]

Afferent Connections (Incoming): These are connections to a neuron. The term "afferent" is derived from Latin, where "ad-" means "to" and "ferre" means "carry." So, afferent connections carry signals to a neuron. In the context of biological neuroscience, these would correspond to the synapses that receive signals from the axons of other neurons onto a neuron's dendrites or cell body (soma).

loadFrom(
json: CreatureInternal | CreatureExport,
validate: boolean,
): void
makeRandomConnection(indx: number): Synapse | null
private
modActivation(focusList?: number[]): void
modBias(focusList?: number[]): void
private
modWeight(focusList?: number[]): void
mutate(
method: { name: string; },
focusList?: number[],
): void

Mutates the creature with the given method

outwardConnections(fromIndx: number): Synapse[]

Efferent Connections (Outgoing): These are connections from a neuron to other neurons. The term "efferent" comes from "ex-" meaning "out of" and "ferre." Efferent connections carry signals away from the neuron. In biological terms, these would be the synapses where a neuron's axon terminals make connections with other neurons' dendrites or cell bodies, transmitting the signal onward.

propagate(
expected: number[],
config: BackPropagationConfig,
): void

Back propagate the creature

propagateUpdate(config: BackPropagationConfig): void

Back propagate the creature

selfConnection(indx: number): SynapseInternal | null
private
subBackConn(focusList?: number[]): void
subConnection(focusList?: number[]): void
subNeuron(focusList?: number[]): void
private
subSelfCon(focusList?: number[]): void
private
swapNodes(focusList?: number[]): void
validate(): void
private
writeCreatures(
neat: Neat,
dir: string,
): void

Static Methods

fromJSON(
json: CreatureInternal | CreatureExport,
validate?: boolean,
): Creature

Convert a json object to a creature

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@stsoftware/neat-ai

Import symbol

import { Creature } from "@stsoftware/neat-ai";

---- OR ----

Import directly with a jsr specifier

import { Creature } from "jsr:@stsoftware/neat-ai";