ann

package module
v0.0.0-...-94c2700 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 14 Imported by: 0

README

gonn-basic

This is a library that creates an artificial neural network (ANN) containing three layers; input, hidden, and output. The library creates a primitive neural network. Future updates and iterations will be written to their own repo.

Usage

To use this module in your own project, run the following command:

go get -u -t github.com/syhv-git/gonn-basic

To develop this package further, create a fork and after cloning the repository to your system, run the command:

go get -u ./...

from the project root.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SumAlongAxis

func SumAlongAxis(axis int, m *mat.Dense) (*mat.Dense, error)

Types

type ANN

type ANN struct {
	Config     Conf
	WHidden    *mat.Dense
	BHidden    *mat.Dense
	WOut       *mat.Dense
	BOut       *mat.Dense
	DBID       uuid.UUID
	Activation func(_, _ int, v float64) float64
	Variance   func(_, _ int, v float64) float64
}

func CreateAccurateANN

func CreateAccurateANN(conf Conf, activator, variance func(_, _ int, v float64) float64, train, test string) (*ANN, error)

func CreateNewANN

func CreateNewANN(conf Conf, activator, variance func(_, _ int, v float64) float64) *ANN

func (*ANN) Delete

func (nn *ANN) Delete(deleter func(dto *DTOANN) error) error

Delete provides a databasing interface

func (*ANN) Load

func (nn *ANN) Load(src string, id bool, loader func(dto *DTOANN) error) (err error)

Load reads saved ANN from file or database. src contains either the file path or uuid.UUID in string form id defines if src is an uuid loader is the function to read from a database

func (*ANN) Predict

func (nn *ANN) Predict(src string) (*mat.Dense, error)

func (*ANN) Store

func (nn *ANN) Store(dst string, id bool, creator func(dto *DTOANN) error) error

Store saves the ANN as a JSON file or to a database. dst contains either the file path or uuid.UUID in string form uuid defines if dst is an ID. creator defines the function to create or update.

The User of this function must maintain whether the record should be created or updated.

func (*ANN) Test

func (nn *ANN) Test(src string)

func (*ANN) Train

func (nn *ANN) Train(src string) error

func (*ANN) Update

func (nn *ANN) Update(updater func(dto *DTOANN) error) error

Update provides a databasing interface

type Conf

type Conf struct {
	Accuracy float64
	InputN   int
	HiddenN  int
	OutputN  int
	Epochs   int
	Rate     float64
}

func NewConfig

func NewConfig(inputSize, hiddenSize, outputSize, epochs int, rate float64) Conf

type DTOANN

type DTOANN struct {
	ID        uuid.UUID
	CreatedAt string
	Conf
	WHidden []byte
	BHidden []byte
	WOut    []byte
	BOut    []byte
}

DTOANN is a Data-Transfer Object for database storage

func (*DTOANN) BeforeCreate

func (dto *DTOANN) BeforeCreate()

BeforeCreate is a gorm hook

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL