nn

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2019 License: MIT Imports: 4 Imported by: 0

README

nn model interface

A nn model interface is defined here that has implementations in the sub directories.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckPoint

type CheckPoint struct {
	Weights [][][]float32
	Biases  [][]float32
}

CheckPoint is the model checkpoint in the form of weights and biases.

type Data

type Data struct {
	X [][]float32
	Y [][]float32
}

Data is a data to be fed to the trainer in the form of a 2D matrix and associated labels. Data.Data has observations, one per row (first index) and features as columns. Y has classes probabilities as columns. Class with max probability is compared against prediction.

func (*Data) ImportCSV

func (d *Data) ImportCSV(rx, ry io.Reader) error

type Operator

type Operator interface {
	// Step through iterations of training process.
	Step(trainingData, validationData *Data) (*TrainingOutput, error)

	// Predict the model outcome.
	Predict(data *Data) (*PredictionOutput, error)

	// Save obtains model checkpoint.
	Save() (*CheckPoint, error)

	// Load re-initializes trainer with a checkpoint.
	Load(checkPoint *CheckPoint) error
}

Operator defines methods to train, predict and checkpoint a model

type PredictionOutput

type PredictionOutput struct {
	Accuracy         float32
	TruthArgmax      []int64
	PredictionArgmax []int64
}

PredictionOutput is the output from prediction.

type TrainingOutput

type TrainingOutput struct {
	CrossEntropy       float32
	TrainingAccuracy   float32
	ValidationAccuracy float32
}

TrainingOutput is the output from each training step.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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