Documentation ¶
Index ¶
- func Encode(w io.Writer, p *Neural) error
- func Learn(p *Neural, samples []Sample, learnRate float64, epochMax int, ...) error
- func NormalizeInputs(samples []Sample)
- func OneHot(n, i int) []float64
- func WriteFile(filename string, p *Neural) error
- type ActivationFunc
- type ActivationType
- type BP
- type BinaryCrossEntropy
- type CostFunc
- type CrossEntropy
- type LayerInfo
- type Linear
- type Logistic
- type Neural
- type ReLU
- type Sample
- type Sigmoid
- type Step
- type Tanh
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeInputs ¶
func NormalizeInputs(samples []Sample)
Types ¶
type ActivationFunc ¶
type ActivationFunc interface { Func(x float64) float64 // f(x) Derivative(fx float64) float64 // {\frac {\partial f(x)}{\partial x}} }
The activation function
func MakeActivationFunc ¶
func MakeActivationFunc(at ActivationType) ActivationFunc
type ActivationType ¶
type ActivationType int
const ( ActLinear ActivationType = iota ActStep ActReLU ActSigmoid ActTanh ActSoftmax )
type BP ¶
type BP struct {
// contains filtered or unexported fields
}
Backpropagation
func (*BP) LearnSample ¶
func (*BP) LearnSamples ¶
func (*BP) SampleCost ¶
func (*BP) SetLearningRate ¶
type BinaryCrossEntropy ¶
type BinaryCrossEntropy struct{}
func (BinaryCrossEntropy) Func ¶
func (BinaryCrossEntropy) Func(t, x []float64) float64
t[i] - ideal output = [0 or 1] x[i] - real output = [0..1]
type CostFunc ¶
type CostFunc interface { Func(t, x []float64) float64 // t - ideal value Derivative(ti, xi float64) float64 }
var CFMeanSquared CostFunc = costMeanSquared{}
type CrossEntropy ¶
type CrossEntropy struct{}
func (CrossEntropy) Derivative ¶
func (CrossEntropy) Derivative(ti, xi float64) float64
func (CrossEntropy) Func ¶
func (CrossEntropy) Func(t, x []float64) float64
t[i] - ideal output = [0 or 1] x[i] - real output = [0..1]
type LayerInfo ¶
type LayerInfo struct { ActivationType ActivationType Neurons int }
func MakeLayers ¶
func MakeLayers(at ActivationType, ds ...int) []LayerInfo
type Neural ¶
type Neural struct {
// contains filtered or unexported fields
}
Feedforward neural network
func (*Neural) GetOutputs ¶
func (*Neural) RandomizeWeights ¶
func (p *Neural) RandomizeWeights()
type Sigmoid ¶
type Sigmoid struct{}
func (Sigmoid) Derivative ¶
sigmoidPrime implements the derivative of the sigmoid function for backpropagation.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.