nnhelper

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: BSD-2-Clause Imports: 8 Imported by: 0

README

Neural Network Helper

GoDoc

Go Language Package with Neural Network helper functions:

  • Create Neural Network using gonn package
  • Read CSV files and convert its values to float format
  • Human Neural Network answer

Look samples at exapmples folder.

Or you can run example in The Go Playground.

Documentation

Overview

Neural Network Helper package. Create and Load Neural Network from file or string. Read CSV files and convert its values from string to float

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(inputCount, hiddenCount, outputCount int, regression bool,
	inpupCsv, targetCsv, resultNN string, print ...bool)

Create Neural Network

func CsvToFloat

func CsvToFloat(in [][]string) (out [][]float64, err error)

CsvToFloat convert string csv array to float

func MaxFloatPosition added in v0.0.3

func MaxFloatPosition(in []float64) int

MaxFloatPosition return position of maximum weight value in float array, or -1 if array is empty

func ReadCsv

func ReadCsv(filePath string) (out [][]float64, err error)

ReadCsvFile read csv file and return float array

func ReadCsvFile

func ReadCsvFile(filePath string) ([][]string, error)

ReadCsvFile read csv file and return string array

func TimeToFloat

func TimeToFloat(time string) (out float64, err error)

TimeToFloat convert string time of day to float value

Types

type NeuralNetwork

type NeuralNetwork struct {
	*gonn.NeuralNetwork
}

Neural Network

func Load

func Load(fileName string) *NeuralNetwork

Load neural network from file

func LoadFromString

func LoadFromString(nnstrig string) *NeuralNetwork

Load neural network from string

func (*NeuralNetwork) Answer

func (nn *NeuralNetwork) Answer(in ...float64) (out []float64)

Get answer from neural network (get weight array), return output array

func (*NeuralNetwork) AnswerToHuman added in v0.0.3

func (nn *NeuralNetwork) AnswerToHuman(out []float64, human []string) (string, int)

AnswerToHuman translate nn answer to human answer, return human string value and index in output array

Directories

Path Synopsis
examples
sam01
Example sam01 description: The task of this neural network is to decide what the game character should do, based on 3 parameters: - Amount of health (from 1 to 100) - The presence of weapons - Number of enemies Depending on the outcome, one of the following decisions may be taken: - Attack - Steal - Run away - Nothing to do Examples for traning: Health Weapons The enemies Decision 50 1 1 Attack 90 1 2 Attack 80 0 1 Attack 30 1 1 Steal 60 1 2 Steal 40 0 1 Steal 90 1 7 Run away 60 1 4 Run away 10 0 1 Run away 60 1 0 Nothing to do 100 0 0 Nothing to do
Example sam01 description: The task of this neural network is to decide what the game character should do, based on 3 parameters: - Amount of health (from 1 to 100) - The presence of weapons - Number of enemies Depending on the outcome, one of the following decisions may be taken: - Attack - Steal - Run away - Nothing to do Examples for traning: Health Weapons The enemies Decision 50 1 1 Attack 90 1 2 Attack 80 0 1 Attack 30 1 1 Steal 60 1 2 Steal 40 0 1 Steal 90 1 7 Run away 60 1 4 Run away 10 0 1 Run away 60 1 0 Nothing to do 100 0 0 Nothing to do
sam02
Example sam02 description: The task of this neural network is to decide what human time of day is selected in input parameter: - time of day in 24hour time fromat: 11:30 or 22:30, etc.
Example sam02 description: The task of this neural network is to decide what human time of day is selected in input parameter: - time of day in 24hour time fromat: 11:30 or 22:30, etc.
sam03
Example sam03 description: Minus by Minus give Plus Input parameters: - first float parameter - second float parameter Output parameters: - result is Plus - result is Minus
Example sam03 description: Minus by Minus give Plus Input parameters: - first float parameter - second float parameter Output parameters: - result is Plus - result is Minus

Jump to

Keyboard shortcuts

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