Documentation
¶
Overview ¶
Package nets provides a standard interface for interacting with neural networks
Index ¶
- func DerivedF(y float32) float32
- func F(x float32) float32
- func ID2Type(id string) (string, error)
- func List(offset, limit int, pattern string, nps paramstores.NetParamStore) ([]types.BriefNet, int, error)
- func MLPTopology(inputs, outputs, hLayers int) []int
- func Required(inputs, outputs, hLayers int, conf config.Config) int
- func Trainer(c chan types.TrainRequest, conf config.Config) error
- type Chromosome
- type MLP
- type Network
- type Neuron
- type Population
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ID2Type ¶
ID2Type takes a string and attempts to extract a net ID from it, when it comes to errors there can be false negatives but not false positives (no error doesn't necessarily mean it's a good ID)
func List ¶
func List(offset, limit int, pattern string, nps paramstores.NetParamStore) ([]types.BriefNet, int, error)
List encapsulates the logic required to fill in BriefNet objects from the IDs of nets in the store
func MLPTopology ¶
MLPTopology returns an array of neurons per layer given the number of inputs, outputs and hidden layers
Types ¶
type Chromosome ¶
type Chromosome struct { ActivationFunc string Fitness float32 // Aptitude for infering outputs for the given inputs HLayers int // Number of hidden layers LearningRate float32 Type string Net Network }
Chromosome represents a neural network configuration
func (*Chromosome) Check ¶
func (c *Chromosome) Check(tr types.TrainRequest, outputs []string, points []pointstores.Point, params config.MLParams) error
Check trains a network with the chromosome's config and updates its fitness based on the accuracy
func (Chromosome) Crossover ¶
func (c Chromosome) Crossover(b Chromosome, n int) []Chromosome
Crossover exchanges n+1 parameters between the chromosomes to create two new configurations
func (*Chromosome) Mutate ¶
func (c *Chromosome) Mutate(gene int)
Mutate randomly alters the given gene
type MLP ¶
type MLP struct {
// contains filtered or unexported fields
}
MLP holds the neurons and thus serves to keep track of the values through the network during training and operation
func MLPFromParams ¶
func MLPFromParams(id string, np paramstores.MLPParams) (*MLP, error)
MLPFromParams returns a multilayer perceptron network initialized with the specified params
func NewMLP ¶
func NewMLP(id string, inputs, outputs []string, chromosome Chromosome) (*MLP, error)
NewMLP returns a multilayer perceptron net built from scratch with the requested inputs, outputs and hidden layers
func (*MLP) Params ¶
func (net *MLP) Params() paramstores.NetParams
Params returns the network's params
func (*MLP) Train ¶
func (net *MLP) Train(points []pointstores.Point, maxEpoch int, errMargin, testSet, tolerance float32) (float32, error)
Train will use the specified input/output pairs to modify the net so the behaviour of its connections is closer to that of the unknown relationships it's intended to mimic
type Network ¶
type Network interface { // This method should return the outputs of feeding the specified inputs into the net Evaluate(inputs map[string]float32) (map[string]float32, error) ID() string // This method should return the net's params Params() paramstores.NetParams // This method should feed the training pairs into the net and update its params in the net param storage when // it's done Train(points []pointstores.Point, maxEpoch int, errMargin, testSet, tolerance float32) (float32, error) }
Network represents the neural net implementation that is being used
func LoadNetwork ¶
func LoadNetwork(id, nType string, nps paramstores.NetParamStore) (Network, error)
LoadNetwork is used to retrieve network params for a given ID and build a network object with them. When they can't be found (nil, nil) will be returned
func NewNetwork ¶
func NewNetwork(id string, inputs, outputs []string, chromosome Chromosome) (Network, error)
NewNetwork returns an initialized neural network of the type specified in the configuration
type Neuron ¶
Neuron holds the state of the smallest component in a neural net
func (*Neuron) RefreshDelta ¶
RefreshDelta will update a neuron's deviation from the desired output
func (*Neuron) RefreshValue ¶
RefreshValue will update a neuron's output with the current value and weight of its inputs
type Population ¶
type Population struct {
// contains filtered or unexported fields
}
Population represents a collection of individuals and their metadata
func NewPopulation ¶
func NewPopulation(params config.MLParams) *Population
NewPopulation creates a new set of individuals and initializes their metadata
func (*Population) Optimal ¶
func (pop *Population) Optimal(tr types.TrainRequest, outputs []string, points []pointstores.Point) (Network, error)
Optimal uses a genetic algorithm to find the config that results in the most accurate net for the given points and returns that net
Directories
¶
Path | Synopsis |
---|---|
Package paramstores contains the implementation of all the supported storage adapters for the network parameters
|
Package paramstores contains the implementation of all the supported storage adapters for the network parameters |