Skip to main content
Home
This release is 133 versions behind 0.167.6 — 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
4 months ago (0.121.0)
Package root>src>Costs.ts
/******************************************************************************* ** COST FUNCTIONS ** https://en.wikipedia.org/wiki/Loss_function *******************************************************************************/ import { BINARY } from "./costs/BINARY.ts"; import { CrossEntropy } from "./costs/CrossEntropy.ts"; import { HINGE } from "./costs/HINGE.ts"; import { MAE } from "./costs/MAE.ts"; import { MAPE } from "./costs/MAPE.ts"; import { MSE } from "./costs/MSE.ts"; import { MSELimit } from "./costs/MSELimit.ts"; import { MSLE } from "./costs/MSLE.ts"; import { TwelveSteps } from "./costs/TwelveSteps.ts"; export interface CostInterface { calculate(target: Float32Array, output: Float32Array): number; } export class Costs { static find(name: string) { switch (name) { /** Cross entropy error */ case "CROSS_ENTROPY": return new CrossEntropy(); /** Mean Squared Error */ case "MSE": return new MSE(); case "MSELimit": return new MSELimit(); /** Binary error */ case "BINARY": return new BINARY(); /** Mean Absolute Error */ case "MAE": return new MAE(); /** Mean Absolute Percentage Error */ case "MAPE": return new MAPE(); /** Mean Squared Logarithmic Error */ case "MSLE": return new MSLE(); /** Hinge loss, for classifiers */ case "HINGE": return new HINGE(); /** Twelve steps Error */ case "12STEPS": return new TwelveSteps(); default: throw new Error(`Unknown: ${name}`); } } }