net

package
v0.0.0-...-70b50b3 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Layer_Activation_Functions map[string]func(*mat.VecDense, Layer) = map[string]func(x *mat.VecDense, L Layer){
	"NA":      NA,
	"SoftMax": SoftMax,
}
View Source
var Node_Activation_Functions map[string]func(float64, *Node) float64 = map[string]func(float64, *Node) float64{
	"NodeLU":    NodeLU,
	"ReLU":      ReLU,
	"Log":       Log,
	"ExpE":      ExpE,
	"ExpSqrtE":  ExpSqrtE,
	"ExpPi":     ExpPi,
	"ExpSqrtPi": ExpSqrtPi,
	"Collatz":   Collatz,
}

▄▀█ █▀▀ ▀█▀ █ █░█ ▄▀█ ▀█▀ █ █▀█ █▄░█   █▀▀ █░█ █▄░█ █▀▀ ▀█▀ █ █▀█ █▄░█ █▀ █▀█ █▄▄ ░█░ █ ▀▄▀ █▀█ ░█░ █ █▄█ █░▀█   █▀░ █▄█ █░▀█ █▄▄ ░█░ █ █▄█ █░▀█ ▄█

we are using a dict to store the funtions. each function will be stored under a key that is a string so that each node can have a key to a actavation function all

dict to map funtions for the Node obj, this is done for dinamic calls to diffrent func. all func must be plan func and not methods with the parma(x float64, n Node) or cannot be placed inside the map

Functions

func Collatz

func Collatz(x float64, n *Node) float64

the hailstone algorithom or Collatz conjecture https://en.wikipedia.org/wiki/Collatz_conjecture

func Compute_loss

func Compute_loss(value float64) float64

func ExpE

func ExpE(x float64, n *Node) float64

raw exponentiation via math.E

func ExpPi

func ExpPi(x float64, n *Node) float64

raw exponentiation via PI

func ExpSqrtE

func ExpSqrtE(x float64, n *Node) float64

raw exponentiation via math.SqrtE

func ExpSqrtPi

func ExpSqrtPi(x float64, n *Node) float64

raw exponentiation via PI

func Log

func Log(x float64, n *Node) float64

natral log: takes a float64 as var x and returns 0 if input < 0 else returns var log10(x)

func NA

func NA(x *mat.VecDense, L Layer)

func NodeLU

func NodeLU(x float64, n *Node) float64

func ReLU

func ReLU(x float64, n *Node) float64

rectified linear: takes a float64 as var x and returns 0 if input < 0 else returns var x

func SoftMax

func SoftMax(x *mat.VecDense, L Layer)

this function is intededed to be usesd for the Output of the forward pass so that the NN can be traned with the prodiction of how corect the model is

Types

type Gorebrum

type Gorebrum struct {
	Layers         []*Layer
	Output         *mat.VecDense
	Width          int
	Depth          int
	Out_dimensions int
	In_dimensions  int
	Log            []string // for training
	// contains filtered or unexported fields
}

func Dcode_model

func Dcode_model(name string) *Gorebrum

func New_Network

func New_Network(
	In_dimensions int,
	Width int,
	Depth int,
	Out_dimensions int) *Gorebrum

this is the functon that makes a new network, New_Network takes 4 variabels as int as fallows

In_dimensions int, (this is the length of the vector that is pasesed into the network)

Width int, (the number of Layers includeing the frist and last Layers)

Depth int, (the lenght of the vectors in the hidden Layers)

Out_dimensions int, (the length of the Output layer)

the function will then return a *Gorebrum:

	type Gorebrum struct {
	input          *mat.VecDense
	Layers         []*Layer
	Output         *mat.VecDense
	Width          int
	Depth          int
	Out_dimensions int
	In_dimensions  int
}

the Output layer will allwase be a softmax actavation

func (*Gorebrum) Computer_fraward_pass

func (N *Gorebrum) Computer_fraward_pass()

the farward pass for the network

func (*Gorebrum) Display_Network

func (N *Gorebrum) Display_Network()

func (*Gorebrum) Encode_model

func (N *Gorebrum) Encode_model(name string)

encodes the network and wrigths the model to a gob file wich

func (Gorebrum) Get_Depth

func (N Gorebrum) Get_Depth() int

func (Gorebrum) Get_Layers

func (N Gorebrum) Get_Layers() []*Layer

func (Gorebrum) Get_Output

func (N Gorebrum) Get_Output() *mat.VecDense

func (Gorebrum) Get_Width

func (N Gorebrum) Get_Width() int

func (Gorebrum) Get_input

func (N Gorebrum) Get_input() *mat.VecDense

func (Gorebrum) Get_layer

func (N Gorebrum) Get_layer(index int) *Layer

func (*Gorebrum) New_Layer

func (net *Gorebrum) New_Layer(length int, inputsLen int, Activation string, Index int)

this is a funtion to add new Nodes to the layer

func (*Gorebrum) Set_Depth

func (N *Gorebrum) Set_Depth(depth int)

func (*Gorebrum) Set_In_dimensions

func (N *Gorebrum) Set_In_dimensions(inDimensions int)

func (*Gorebrum) Set_Layer

func (N *Gorebrum) Set_Layer(index int, layer *Layer)

setters for the network

func (*Gorebrum) Set_Out_dimensions

func (N *Gorebrum) Set_Out_dimensions(outDimensions int)

func (*Gorebrum) Set_Output

func (N *Gorebrum) Set_Output(output *mat.VecDense)

func (*Gorebrum) Set_Width

func (N *Gorebrum) Set_Width(width int)

func (*Gorebrum) Set_inputs

func (N *Gorebrum) Set_inputs(inputs []float64)

sets an input to the seme vec that is passed to it

func (*Gorebrum) ToXML

func (N *Gorebrum) ToXML() string

this displays the network in all its glory and wonder

func (*Gorebrum) Update_Output

func (N *Gorebrum) Update_Output()

this updates the Output for the network

type Layer

type Layer struct {
	Output     *mat.VecDense
	Nodes      []*Node
	Activation string

	Index int
	Log   []string // for training
	// contains filtered or unexported fields
}

this is the structur of the Layers in the network the goal is to apstrat all the

func (Layer) Compute_Layer

func (L Layer) Compute_Layer()

Compute_Layer

func (Layer) Display_info

func (L Layer) Display_info()

func (*Layer) Get_Activation

func (L *Layer) Get_Activation() string

func (*Layer) Get_Index

func (L *Layer) Get_Index() int

func (*Layer) Get_Nodes

func (L *Layer) Get_Nodes() []*Node

func (*Layer) Get_parent_network

func (L *Layer) Get_parent_network() *Gorebrum

func (*Layer) New_Node

func (L *Layer) New_Node(Weights []float64, Bias float64, Activation string, i int)

makes a new node from the layer

func (*Layer) Set_Activation

func (L *Layer) Set_Activation(activation string)

func (*Layer) Set_Index

func (L *Layer) Set_Index(index int)

func (*Layer) Set_Nodes

func (L *Layer) Set_Nodes(nodes []*Node)

func (*Layer) Set_Output

func (L *Layer) Set_Output(output *mat.VecDense)

func (*Layer) Set_parent_network

func (L *Layer) Set_parent_network(parent_network *Gorebrum)

setters

func (Layer) ToXML

func (L Layer) ToXML() string

type Node

type Node struct {
	Weights *mat.VecDense

	Bias       float64
	Activation string
	Output     float64

	Index int
	Log   []string // for training
	// contains filtered or unexported fields
}

this is the struct for creating Nodes this will eventualy be a nural network

func New_Node

func New_Node(Weights []float64, Bias float64, Activation string) *Node

makes a node form a static state

func (*Node) Compute_node

func (n *Node) Compute_node()

method for computing the Output of a node

func (Node) Display_info

func (n Node) Display_info()

func (Node) Get_Activation

func (n Node) Get_Activation() string

reternds the activation of the network.

func (Node) Get_Bias

func (n Node) Get_Bias() float64

returns the bias of the node

func (Node) Get_Weights

func (n Node) Get_Weights() *mat.VecDense

returns the weights of the node as a *mat.VecDence

func (Node) Get_input

func (n Node) Get_input() *mat.VecDense

this function grabs the Outputs from the layer before it. unless it is the frist layer, in that case the input for the network is used

func (Node) Get_output

func (n Node) Get_output() float64

returns the output of the node

func (Node) Get_parent_layer

func (n Node) Get_parent_layer() *Layer

returs the address of the layer that the node is a part of

func (*Node) Set_Activation

func (n *Node) Set_Activation(Activation string)

func (*Node) Set_Bias

func (n *Node) Set_Bias(Bias float64)

sets the Bias of a node to a float64

func (*Node) Set_Output

func (n *Node) Set_Output(Output float64)

func (*Node) Set_Weights

func (n *Node) Set_Weights(Weights *mat.VecDense)

sets the weights of the node to a *mat.VecDence

func (*Node) Set_input

func (n *Node) Set_input(input *mat.VecDense)

func (*Node) Set_parent_layer

func (n *Node) Set_parent_layer(Layer *Layer)

func (Node) ToXML

func (n Node) ToXML() string

type Trainer

type Trainer struct {
	Traing_algoithms map[string]func(*Trainer)
	// contains filtered or unexported fields
}

func New_trainer

func New_trainer(network *Gorebrum) *Trainer

this creates a new training obj for training a model on a data set doing it this way will give is freedom to implement different training strategies

func (*Trainer) Compute_Training_Pass

func (T *Trainer) Compute_Training_Pass()

Jump to

Keyboard shortcuts

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