Skip to main content
Module

x/neat_ai/mod.ts>Creature

DenoJS Neural network project written in typescript.
Go to Latest
class Creature
implements CreatureInternal
import { Creature } from "https://deno.land/x/neat_ai@v0.25.0/mod.ts";

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[]>
DEBUG
input: number
neurons: Neuron[]
output: number
optional
score: number
readonly
state: CreatureState
synapses: Synapse[]
optional
tags: TagInterface[]
optional
uuid: string

Methods

private
addBackConn(focusList?: number[])
private
addSelfCon(focusList?: number[])
private
evaluateData(
json: { input: number[]; output: number[]; }[],
cost: CostInterface,
feedbackLoop: boolean,
): { error: number; count: number; }
private
initialize(options: { layers?: { squash?: string; count: number; }[]; })
private
insertNeuron(neuron: Neuron)
private
modActivation(focusList?: number[])
private
modWeight(focusList?: number[])
private
subBackConn(focusList?: number[])
private
subSelfCon(focusList?: number[])
private
swapNodes(focusList?: number[])
private
writeCreatures(neat: Neat, dir: string)
activate(input: number[], feedbackLoop?)

Activates the creature without calculating traces and such

activateAndTrace(input: number[], feedbackLoop?)

Activates the creature

addConnection(focusList?: number[], options?)
addNode(focusList?: number[])
applyLearnings(config: BackPropagationConfig)

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 node to the to node

disconnect(from: number, to: number)

Disconnects the from node from the to node

evaluateDir(
dataDir: string,
cost: CostInterface,
feedbackLoop: boolean,
)

Tests a set and returns the error and elapsed time

evolveDataSet(dataSet: DataRecordInterface[], options: NeatOptions)

Evolves the creature to reach a lower error on a dataset

evolveDir(dataSetDir: string, options: NeatOptions)

Evolves the creature to reach a lower error on a dataset

Convert the creature to a json object

fix()

Fix the creature

fromConnections(from: number): Synapse[]
getActivation(indx: number)
getNeuron(pos: number): Neuron
getSynapse(from: number, to: number): Synapse | null
inFocus(
index: number,
focusList?: number[],
checked?,
)
loadFrom(json: CreatureInternal | CreatureExport, validate: boolean)
makeRandomConnection(indx: number)
modBias(focusList?: number[])
mutate(method: { name: string; }, focusList?: number[])

Mutates the creature with the given method

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

Back propagate the creature

propagateUpdate(config: BackPropagationConfig)

Back propagate the creature

selfConnection(indx: number): SynapseInternal | null
subConnection(focusList?: number[])
subNode(focusList?: number[])
toConnections(to: number): Synapse[]
validate(options?: { nodes?: number; connections?: number; })

Validate the creature

Static Methods

fromJSON(json: CreatureInternal | CreatureExport, validate?)

Convert a json object to a creature