Documentation

Overview

    Package neuralnetwork reproduces multilayer perceptron based on Andreas Mueller implementation + float 32 implementation + weight decay + batch normalization

    Index

    Examples

    Constants

    This section is empty.

    Variables

    View Source
    var Activations32 = map[string]func(z blas32General){
    	"identity": func(z blas32General) {},
    	"logistic": func(z blas32General) {
    		for row, zpos := 0, 0; row < z.Rows; row, zpos = row+1, zpos+z.Stride {
    			for col := 0; col < z.Cols; col++ {
    				z.Data[zpos+col] = 1 / (1 + M32.Exp(-z.Data[zpos+col]))
    			}
    		}
    	},
    	"tanh": func(z blas32General) {
    		for row, zpos := 0, 0; row < z.Rows; row, zpos = row+1, zpos+z.Stride {
    			for col := 0; col < z.Cols; col++ {
    				z.Data[zpos+col] = M32.Tanh(-z.Data[zpos+col])
    			}
    		}
    	},
    	"relu": func(z blas32General) {
    		for row, zpos := 0, 0; row < z.Rows; row, zpos = row+1, zpos+z.Stride {
    			for col := 0; col < z.Cols; col++ {
    				if z.Data[zpos+col] < 0 {
    					z.Data[zpos+col] = 0
    				}
    			}
    		}
    	},
    	"softmax": func(z blas32General) {
    		for row, zpos := 0, 0; row < z.Rows; row, zpos = row+1, zpos+z.Stride {
    			sum := float32(0)
    			for col := 0; col < z.Cols; col++ {
    
    				z.Data[zpos+col] = M32.Exp(z.Data[zpos+col])
    				sum += z.Data[zpos+col]
    			}
    			for col := 0; col < z.Cols; col++ {
    				z.Data[zpos+col] /= sum
    			}
    		}
    	},
    }

      Activations32 is a map containing the inplace_activation functions

      View Source
      var Activations64 = map[string]func(z blas64General){
      	"identity": func(z blas64General) {},
      	"logistic": func(z blas64General) {
      		for row, zpos := 0, 0; row < z.Rows; row, zpos = row+1, zpos+z.Stride {
      			for col := 0; col < z.Cols; col++ {
      				z.Data[zpos+col] = 1 / (1 + M64.Exp(-z.Data[zpos+col]))
      			}
      		}
      	},
      	"tanh": func(z blas64General) {
      		for row, zpos := 0, 0; row < z.Rows; row, zpos = row+1, zpos+z.Stride {
      			for col := 0; col < z.Cols; col++ {
      				z.Data[zpos+col] = M64.Tanh(-z.Data[zpos+col])
      			}
      		}
      	},
      	"relu": func(z blas64General) {
      		for row, zpos := 0, 0; row < z.Rows; row, zpos = row+1, zpos+z.Stride {
      			for col := 0; col < z.Cols; col++ {
      				if z.Data[zpos+col] < 0 {
      					z.Data[zpos+col] = 0
      				}
      			}
      		}
      	},
      	"softmax": func(z blas64General) {
      		for row, zpos := 0, 0; row < z.Rows; row, zpos = row+1, zpos+z.Stride {
      			sum := float64(0)
      			for col := 0; col < z.Cols; col++ {
      
      				z.Data[zpos+col] = M64.Exp(z.Data[zpos+col])
      				sum += z.Data[zpos+col]
      			}
      			for col := 0; col < z.Cols; col++ {
      				z.Data[zpos+col] /= sum
      			}
      		}
      	},
      }

        Activations64 is a map containing the inplace_activation functions

        View Source
        var Derivatives32 = map[string]func(Z, deltas blas32General){
        	"identity": func(Z, deltas blas32General) {
        	},
        	"logistic": func(Z, deltas blas32General) {
        		for row, zpos, dpos := 0, 0, 0; row < Z.Rows; row, zpos, dpos = row+1, zpos+Z.Stride, dpos+deltas.Stride {
        			for col := 0; col < Z.Cols; col++ {
        				z := Z.Data[zpos+col]
        				deltas.Data[dpos+col] *= z * (1 - z)
        			}
        		}
        	},
        	"tanh": func(Z, deltas blas32General) {
        		for row, zpos, dpos := 0, 0, 0; row < Z.Rows; row, zpos, dpos = row+1, zpos+Z.Stride, dpos+deltas.Stride {
        			for col := 0; col < Z.Cols; col++ {
        				z := Z.Data[zpos+col]
        				deltas.Data[dpos+col] *= 1 - z*z
        			}
        		}
        	},
        	"relu": func(Z, deltas blas32General) {
        		for row, zpos, dpos := 0, 0, 0; row < Z.Rows; row, zpos, dpos = row+1, zpos+Z.Stride, dpos+deltas.Stride {
        			for col := 0; col < Z.Cols; col++ {
        				if Z.Data[zpos+col] == 0 {
        					deltas.Data[dpos+col] = 0
        				}
        			}
        		}
        	},
        }

          Derivatives32 is a map of functions which multiply deltas with derivative of activation function

          View Source
          var Derivatives64 = map[string]func(Z, deltas blas64General){
          	"identity": func(Z, deltas blas64General) {
          	},
          	"logistic": func(Z, deltas blas64General) {
          		for row, zpos, dpos := 0, 0, 0; row < Z.Rows; row, zpos, dpos = row+1, zpos+Z.Stride, dpos+deltas.Stride {
          			for col := 0; col < Z.Cols; col++ {
          				z := Z.Data[zpos+col]
          				deltas.Data[dpos+col] *= z * (1 - z)
          			}
          		}
          	},
          	"tanh": func(Z, deltas blas64General) {
          		for row, zpos, dpos := 0, 0, 0; row < Z.Rows; row, zpos, dpos = row+1, zpos+Z.Stride, dpos+deltas.Stride {
          			for col := 0; col < Z.Cols; col++ {
          				z := Z.Data[zpos+col]
          				deltas.Data[dpos+col] *= 1 - z*z
          			}
          		}
          	},
          	"relu": func(Z, deltas blas64General) {
          		for row, zpos, dpos := 0, 0, 0; row < Z.Rows; row, zpos, dpos = row+1, zpos+Z.Stride, dpos+deltas.Stride {
          			for col := 0; col < Z.Cols; col++ {
          				if Z.Data[zpos+col] == 0 {
          					deltas.Data[dpos+col] = 0
          				}
          			}
          		}
          	},
          }

            Derivatives64 is a map of functions which multiply deltas with derivative of activation function

            View Source
            var LossFunctions32 = map[string]func(y, h blas32General) float32{
            	"square_loss": func(y, h blas32General) float32 {
            		sum := float32(0)
            		for row, hpos, ypos := 0, 0, 0; row < y.Rows; row, hpos, ypos = row+1, hpos+h.Stride, ypos+y.Stride {
            			for col := 0; col < y.Cols; col++ {
            				e := h.Data[hpos+col] - y.Data[ypos+col]
            				sum += e * e
            			}
            		}
            		return sum / 2 / float32(h.Rows)
            	},
            	"log_loss": func(y, h blas32General) float32 {
            		sum := float32(0)
            		hmin, hmax := M32.Nextafter(0, 1), M32.Nextafter(1, 0)
            		for row, hpos, ypos := 0, 0, 0; row < y.Rows; row, hpos, ypos = row+1, hpos+h.Stride, ypos+y.Stride {
            			for col := 0; col < y.Cols; col++ {
            				hval := h.Data[hpos+col]
            				if hval < hmin {
            					hval = hmin
            				} else if hval > hmax {
            					hval = hmax
            				}
            				if y.Data[ypos+col] != 0 {
            					sum += -y.Data[ypos+col] * M32.Log(hval)
            				}
            			}
            		}
            		return sum / float32(h.Rows)
            	},
            	"binary_log_loss": func(y, h blas32General) float32 {
            		sum := float32(0)
            		hmin, hmax := M32.Nextafter(0, 1), M32.Nextafter(1, 0)
            		for row, hpos, ypos := 0, 0, 0; row < y.Rows; row, hpos, ypos = row+1, hpos+h.Stride, ypos+y.Stride {
            			for col := 0; col < y.Cols; col++ {
            				hval := h.Data[hpos+col]
            				if hval < hmin {
            					hval = hmin
            				} else if hval > hmax {
            					hval = hmax
            				}
            				sum += -y.Data[ypos+col]*M32.Log(hval) - (1-y.Data[ypos+col])*M32.Log1p(-hval)
            			}
            		}
            		return sum / float32(h.Rows)
            	},
            }

              LossFunctions32 is a map for loss functions

              View Source
              var LossFunctions64 = map[string]func(y, h blas64General) float64{
              	"square_loss": func(y, h blas64General) float64 {
              		sum := float64(0)
              		for row, hpos, ypos := 0, 0, 0; row < y.Rows; row, hpos, ypos = row+1, hpos+h.Stride, ypos+y.Stride {
              			for col := 0; col < y.Cols; col++ {
              				e := h.Data[hpos+col] - y.Data[ypos+col]
              				sum += e * e
              			}
              		}
              		return sum / 2 / float64(h.Rows)
              	},
              	"log_loss": func(y, h blas64General) float64 {
              		sum := float64(0)
              		hmin, hmax := M64.Nextafter(0, 1), M64.Nextafter(1, 0)
              		for row, hpos, ypos := 0, 0, 0; row < y.Rows; row, hpos, ypos = row+1, hpos+h.Stride, ypos+y.Stride {
              			for col := 0; col < y.Cols; col++ {
              				hval := h.Data[hpos+col]
              				if hval < hmin {
              					hval = hmin
              				} else if hval > hmax {
              					hval = hmax
              				}
              				if y.Data[ypos+col] != 0 {
              					sum += -y.Data[ypos+col] * M64.Log(hval)
              				}
              			}
              		}
              		return sum / float64(h.Rows)
              	},
              	"binary_log_loss": func(y, h blas64General) float64 {
              		sum := float64(0)
              		hmin, hmax := M64.Nextafter(0, 1), M64.Nextafter(1, 0)
              		for row, hpos, ypos := 0, 0, 0; row < y.Rows; row, hpos, ypos = row+1, hpos+h.Stride, ypos+y.Stride {
              			for col := 0; col < y.Cols; col++ {
              				hval := h.Data[hpos+col]
              				if hval < hmin {
              					hval = hmin
              				} else if hval > hmax {
              					hval = hmax
              				}
              				sum += -y.Data[ypos+col]*M64.Log(hval) - (1-y.Data[ypos+col])*M64.Log1p(-hval)
              			}
              		}
              		return sum / float64(h.Rows)
              	},
              }

                LossFunctions64 is a map for loss functions

                View Source
                var M32 = struct {
                	Ceil       func(float32) float32
                	Sqrt       func(float32) float32
                	Pow        func(float32, float32) float32
                	IsInf      func(float32, int) bool
                	Abs        func(float32) float32
                	Exp        func(float32) float32
                	Tanh       func(float32) float32
                	Log        func(float32) float32
                	Log1p      func(float32) float32
                	MaxFloat32 float32
                	Inf        func(int) float32
                	IsNaN      func(float32) bool
                	Nextafter  func(x, y float32) float32
                	MaxFloatXX floatXX
                }{
                	Ceil: m32.Ceil, Sqrt: m32.Sqrt, Pow: m32.Pow, IsInf: m32.IsInf, Abs: m32.Abs, Exp: m32.Exp, Tanh: m32.Tanh, Log: m32.Log, Log1p: m32.Log1p,
                	MaxFloat32: m32.MaxFloat32, Inf: m32.Inf, IsNaN: m32.IsNaN, Nextafter: m32.Nextafter, MaxFloatXX: m32.MaxFloat32}

                  M32 has funcs for float32 math

                  View Source
                  var M64 = struct {
                  	Ceil       func(float64) float64
                  	Sqrt       func(float64) float64
                  	Pow        func(float64, float64) float64
                  	IsInf      func(float64, int) bool
                  	Abs        func(float64) float64
                  	Exp        func(float64) float64
                  	Tanh       func(float64) float64
                  	Log        func(float64) float64
                  	Log1p      func(float64) float64
                  	MaxFloat64 float64
                  	Inf        func(int) float64
                  	IsNaN      func(float64) bool
                  	Nextafter  func(x, y float64) float64
                  }{Ceil: m64.Ceil, Sqrt: m64.Sqrt, Pow: m64.Pow, IsInf: m64.IsInf, Abs: m64.Abs, Exp: m64.Exp, Tanh: m64.Tanh, Log: m64.Log, Log1p: m64.Log1p,
                  	MaxFloat64: m64.MaxFloat64, Inf: m64.Inf, IsNaN: m64.IsNaN, Nextafter: m64.Nextafter}

                    M64 has funcs for float64 math

                    View Source
                    var MXX = M32

                      MXX has funcs for floatXX math

                      View Source
                      var MaxIdxXX = MaxIdx32

                        MaxIdxXX ...

                        View Source
                        var Regressors = []base.Predicter{&MLPRegressor{}}

                          Regressors is the list of regressors in this package

                          Functions

                          func MaxIdx32

                          func MaxIdx32(a []float32) int

                            MaxIdx32 ...

                            func MaxIdx64

                            func MaxIdx64(a []float64) int

                              MaxIdx64 ...

                              Types

                              type AdamOptimizer32

                              type AdamOptimizer32 struct {
                              	Params                []float32
                              	LearningRateInit      float32
                              	LearningRate          float32
                              	Beta1, Beta2, Epsilon float32
                              	// contains filtered or unexported fields
                              }

                                AdamOptimizer32 is the stochastic adam optimizer

                                type AdamOptimizer64

                                type AdamOptimizer64 struct {
                                	Params                []float64
                                	LearningRateInit      float64
                                	LearningRate          float64
                                	Beta1, Beta2, Epsilon float64
                                	// contains filtered or unexported fields
                                }

                                  AdamOptimizer64 is the stochastic adam optimizer

                                  type BaseMultilayerPerceptron32

                                  type BaseMultilayerPerceptron32 struct {
                                  	Activation         string  `json:"activation"`
                                  	Solver             string  `json:"solver"`
                                  	Alpha              float32 `json:"alpha"`
                                  	WeightDecay        float32 `json:"weight_decay"`
                                  	BatchSize          int     `json:"batch_size"`
                                  	BatchNormalize     bool
                                  	LearningRate       string           `json:"learning_rate"`
                                  	LearningRateInit   float32          `json:"learning_rate_init"`
                                  	PowerT             float32          `json:"power_t"`
                                  	MaxIter            int              `json:"max_iter"`
                                  	LossFuncName       string           `json:"loss_func_name"`
                                  	HiddenLayerSizes   []int            `json:"hidden_layer_sizes"`
                                  	Shuffle            bool             `json:"shuffle"`
                                  	RandomState        base.RandomState `json:"random_state"`
                                  	Tol                float32          `json:"tol"`
                                  	Verbose            bool             `json:"verbose"`
                                  	WarmStart          bool             `json:"warm_start"`
                                  	Momentum           float32          `json:"momentum"`
                                  	NesterovsMomentum  bool             `json:"nesterovs_momentum"`
                                  	EarlyStopping      bool             `json:"early_stopping"`
                                  	ValidationFraction float32          `json:"validation_fraction"`
                                  	Beta1              float32          `json:"beta_1"`
                                  	Beta2              float32          `json:"beta_2"`
                                  	Epsilon            float32          `json:"epsilon"`
                                  	NIterNoChange      int              `json:"n_iter_no_change"`
                                  
                                  	// Outputs
                                  	NLayers       int
                                  	NIter         int
                                  	NOutputs      int
                                  	Intercepts    [][]float32     `json:"intercepts_"`
                                  	Coefs         []blas32General `json:"coefs_"`
                                  	OutActivation string          `json:"out_activation_"`
                                  	Loss          float32
                                  
                                  	LossCurve           []float32
                                  	ValidationScores    []float32
                                  	BestValidationScore float32
                                  	BestLoss            float32
                                  	NoImprovementCount  int
                                  	// contains filtered or unexported fields
                                  }

                                    BaseMultilayerPerceptron32 closely matches sklearn/neural_network/multilayer_perceptron.py

                                    func NewBaseMultilayerPerceptron32

                                    func NewBaseMultilayerPerceptron32() *BaseMultilayerPerceptron32

                                      NewBaseMultilayerPerceptron32 returns a BaseMultilayerPerceptron32 with defaults

                                      func (*BaseMultilayerPerceptron32) Fit

                                      func (mlp *BaseMultilayerPerceptron32) Fit(X, Y Matrix)

                                        Fit compute Coefs and Intercepts

                                        Example (Mnist)
                                        Output:
                                        
                                        ok
                                        

                                        func (*BaseMultilayerPerceptron32) GetNOutputs

                                        func (mlp *BaseMultilayerPerceptron32) GetNOutputs() int

                                          GetNOutputs returns output columns number for Y to pass to predict

                                          func (*BaseMultilayerPerceptron32) IsClassifier

                                          func (mlp *BaseMultilayerPerceptron32) IsClassifier() bool

                                            IsClassifier return true if LossFuncName is not square_loss

                                            func (*BaseMultilayerPerceptron32) Predict

                                            func (mlp *BaseMultilayerPerceptron32) Predict(X mat.Matrix, Y Mutable)

                                              Predict do forward pass and fills Y (Y must be Mutable)

                                              func (*BaseMultilayerPerceptron32) Score

                                              func (mlp *BaseMultilayerPerceptron32) Score(Xmatrix, Ymatrix mat.Matrix) float64

                                                Score for BaseMultiLayerPerceptron32 is R2Score or Accuracy depending on LossFuncName

                                                func (*BaseMultilayerPerceptron32) SetParams

                                                func (mlp *BaseMultilayerPerceptron32) SetParams(params map[string]interface{})

                                                  SetParams allow settings params from a map. (used by Unmarshal)

                                                  func (*BaseMultilayerPerceptron32) Unmarshal

                                                  func (mlp *BaseMultilayerPerceptron32) Unmarshal(buf []byte) error

                                                    Unmarshal init params intercepts_ coefs_ from json

                                                    type BaseMultilayerPerceptron64

                                                    type BaseMultilayerPerceptron64 struct {
                                                    	Activation         string  `json:"activation"`
                                                    	Solver             string  `json:"solver"`
                                                    	Alpha              float64 `json:"alpha"`
                                                    	WeightDecay        float64 `json:"weight_decay"`
                                                    	BatchSize          int     `json:"batch_size"`
                                                    	BatchNormalize     bool
                                                    	LearningRate       string           `json:"learning_rate"`
                                                    	LearningRateInit   float64          `json:"learning_rate_init"`
                                                    	PowerT             float64          `json:"power_t"`
                                                    	MaxIter            int              `json:"max_iter"`
                                                    	LossFuncName       string           `json:"loss_func_name"`
                                                    	HiddenLayerSizes   []int            `json:"hidden_layer_sizes"`
                                                    	Shuffle            bool             `json:"shuffle"`
                                                    	RandomState        base.RandomState `json:"random_state"`
                                                    	Tol                float64          `json:"tol"`
                                                    	Verbose            bool             `json:"verbose"`
                                                    	WarmStart          bool             `json:"warm_start"`
                                                    	Momentum           float64          `json:"momentum"`
                                                    	NesterovsMomentum  bool             `json:"nesterovs_momentum"`
                                                    	EarlyStopping      bool             `json:"early_stopping"`
                                                    	ValidationFraction float64          `json:"validation_fraction"`
                                                    	Beta1              float64          `json:"beta_1"`
                                                    	Beta2              float64          `json:"beta_2"`
                                                    	Epsilon            float64          `json:"epsilon"`
                                                    	NIterNoChange      int              `json:"n_iter_no_change"`
                                                    
                                                    	// Outputs
                                                    	NLayers       int
                                                    	NIter         int
                                                    	NOutputs      int
                                                    	Intercepts    [][]float64     `json:"intercepts_"`
                                                    	Coefs         []blas64General `json:"coefs_"`
                                                    	OutActivation string          `json:"out_activation_"`
                                                    	Loss          float64
                                                    
                                                    	LossCurve           []float64
                                                    	ValidationScores    []float64
                                                    	BestValidationScore float64
                                                    	BestLoss            float64
                                                    	NoImprovementCount  int
                                                    	// contains filtered or unexported fields
                                                    }

                                                      BaseMultilayerPerceptron64 closely matches sklearn/neural_network/multilayer_perceptron.py

                                                      func NewBaseMultilayerPerceptron64

                                                      func NewBaseMultilayerPerceptron64() *BaseMultilayerPerceptron64

                                                        NewBaseMultilayerPerceptron64 returns a BaseMultilayerPerceptron64 with defaults

                                                        func (*BaseMultilayerPerceptron64) Fit

                                                        func (mlp *BaseMultilayerPerceptron64) Fit(X, Y Matrix)

                                                          Fit compute Coefs and Intercepts

                                                          func (*BaseMultilayerPerceptron64) GetNOutputs

                                                          func (mlp *BaseMultilayerPerceptron64) GetNOutputs() int

                                                            GetNOutputs returns output columns number for Y to pass to predict

                                                            func (*BaseMultilayerPerceptron64) IsClassifier

                                                            func (mlp *BaseMultilayerPerceptron64) IsClassifier() bool

                                                              IsClassifier return true if LossFuncName is not square_loss

                                                              func (*BaseMultilayerPerceptron64) Predict

                                                              func (mlp *BaseMultilayerPerceptron64) Predict(X mat.Matrix, Y Mutable)

                                                                Predict do forward pass and fills Y (Y must be Mutable)

                                                                func (*BaseMultilayerPerceptron64) Score

                                                                func (mlp *BaseMultilayerPerceptron64) Score(Xmatrix, Ymatrix mat.Matrix) float64

                                                                  Score for BaseMultiLayerPerceptron64 is R2Score or Accuracy depending on LossFuncName

                                                                  func (*BaseMultilayerPerceptron64) SetParams

                                                                  func (mlp *BaseMultilayerPerceptron64) SetParams(params map[string]interface{})

                                                                    SetParams allow settings params from a map. (used by Unmarshal)

                                                                    func (*BaseMultilayerPerceptron64) Unmarshal

                                                                    func (mlp *BaseMultilayerPerceptron64) Unmarshal(buf []byte) error

                                                                      Unmarshal init params intercepts_ coefs_ from json

                                                                      type Float32Slice

                                                                      type Float32Slice []float32

                                                                        Float32Slice implements sort.Interface.

                                                                        func (Float32Slice) Len

                                                                        func (p Float32Slice) Len() int

                                                                        func (Float32Slice) Less

                                                                        func (p Float32Slice) Less(i, j int) bool

                                                                        func (Float32Slice) Swap

                                                                        func (p Float32Slice) Swap(i, j int)

                                                                        type Float64Slice

                                                                        type Float64Slice []float64

                                                                          Float64Slice implements sort.Interface.

                                                                          func (Float64Slice) Len

                                                                          func (p Float64Slice) Len() int

                                                                          func (Float64Slice) Less

                                                                          func (p Float64Slice) Less(i, j int) bool

                                                                          func (Float64Slice) Swap

                                                                          func (p Float64Slice) Swap(i, j int)

                                                                          type General32

                                                                          type General32 blas32.General

                                                                            General32 is like blas32.General

                                                                            func FromDense32

                                                                            func FromDense32(dst Mutable, dense General32) General32

                                                                              FromDense32 fills dst (mat.Mutable) with src (mat.Dense)

                                                                              func ToDense32

                                                                              func ToDense32(m Matrix) General32

                                                                                ToDense32 returns w view of m if m is a RawMatrixer, et returns a dense copy of m

                                                                                func (General32) At

                                                                                func (mat General32) At(r, c int) float64

                                                                                  At returns value at row,col

                                                                                  func (*General32) Copy

                                                                                  func (mat *General32) Copy(a Matrix)

                                                                                    Copy fills receiver with input matrix

                                                                                    func (General32) Dims

                                                                                    func (mat General32) Dims() (r, c int)

                                                                                      Dims return number of rows and columns

                                                                                      func (General32) Len

                                                                                      func (mat General32) Len() int

                                                                                        Len returns row count

                                                                                        func (General32) Less

                                                                                        func (mat General32) Less(i, j int) bool

                                                                                          Less compare rows. panics if Cols!=1

                                                                                          func (General32) RawMatrix

                                                                                          func (mat General32) RawMatrix() blas32General

                                                                                            RawMatrix return blas raw matrix

                                                                                            func (General32) RawRowView

                                                                                            func (mat General32) RawRowView(i int) []float32

                                                                                              RawRowView returns row as a float slice

                                                                                              func (General32) RowSlice

                                                                                              func (mat General32) RowSlice(i, j int) General32

                                                                                                RowSlice provides view on submatrix(startRow,endRow) as General32 returned matrix can be casted to *General32

                                                                                                func (General32) Set

                                                                                                func (mat General32) Set(r, c int, v float64)

                                                                                                  Set set value at row,col

                                                                                                  func (General32) Slice

                                                                                                  func (mat General32) Slice(i, j, k, l int) Matrix

                                                                                                    Slice provides view on submatrix(startRow,endRow,startCol,endCol) returned matrix can be casted to *General32

                                                                                                    func (*General32) SumRows

                                                                                                    func (mat *General32) SumRows(a General32)

                                                                                                      SumRows sums rows of a into mat

                                                                                                      func (General32) Swap

                                                                                                      func (mat General32) Swap(i, j int)

                                                                                                        Swap permutes 2 lines {

                                                                                                        func (General32) T

                                                                                                        func (mat General32) T() Matrix

                                                                                                          T returns transposed Matrix

                                                                                                          type General64

                                                                                                          type General64 blas64.General

                                                                                                            General64 is like blas64.General

                                                                                                            func FromDense64

                                                                                                            func FromDense64(dst Mutable, dense General64) General64

                                                                                                              FromDense64 fills dst (mat.Mutable) with src (mat.Dense)

                                                                                                              func ToDense64

                                                                                                              func ToDense64(m Matrix) General64

                                                                                                                ToDense64 returns w view of m if m is a RawMatrixer, et returns a dense copy of m

                                                                                                                func (General64) At

                                                                                                                func (mat General64) At(r, c int) float64

                                                                                                                  At returns value at row,col

                                                                                                                  func (*General64) Copy

                                                                                                                  func (mat *General64) Copy(a Matrix)

                                                                                                                    Copy fills receiver with input matrix

                                                                                                                    func (General64) Dims

                                                                                                                    func (mat General64) Dims() (r, c int)

                                                                                                                      Dims return number of rows and columns

                                                                                                                      func (General64) Len

                                                                                                                      func (mat General64) Len() int

                                                                                                                        Len returns row count

                                                                                                                        func (General64) Less

                                                                                                                        func (mat General64) Less(i, j int) bool

                                                                                                                          Less compare rows. panics if Cols!=1

                                                                                                                          func (General64) RawMatrix

                                                                                                                          func (mat General64) RawMatrix() blas64General

                                                                                                                            RawMatrix return blas raw matrix

                                                                                                                            func (General64) RawRowView

                                                                                                                            func (mat General64) RawRowView(i int) []float64

                                                                                                                              RawRowView returns row as a float slice

                                                                                                                              func (General64) RowSlice

                                                                                                                              func (mat General64) RowSlice(i, j int) General64

                                                                                                                                RowSlice provides view on submatrix(startRow,endRow) as General64 returned matrix can be casted to *General64

                                                                                                                                func (General64) Set

                                                                                                                                func (mat General64) Set(r, c int, v float64)

                                                                                                                                  Set set value at row,col

                                                                                                                                  func (General64) Slice

                                                                                                                                  func (mat General64) Slice(i, j, k, l int) Matrix

                                                                                                                                    Slice provides view on submatrix(startRow,endRow,startCol,endCol) returned matrix can be casted to *General64

                                                                                                                                    func (*General64) SumRows

                                                                                                                                    func (mat *General64) SumRows(a General64)

                                                                                                                                      SumRows sums rows of a into mat

                                                                                                                                      func (General64) Swap

                                                                                                                                      func (mat General64) Swap(i, j int)

                                                                                                                                        Swap permutes 2 lines {

                                                                                                                                        func (General64) T

                                                                                                                                        func (mat General64) T() Matrix

                                                                                                                                          T returns transposed Matrix

                                                                                                                                          type GeneralXX

                                                                                                                                          type GeneralXX = General32

                                                                                                                                            GeneralXX is for easy tranposition to float32 or float64

                                                                                                                                            type LabelBinarizer32

                                                                                                                                            type LabelBinarizer32 struct {
                                                                                                                                            	NegLabel, PosLabel float32
                                                                                                                                            	Classes            [][]float32
                                                                                                                                            }

                                                                                                                                              LabelBinarizer32 Binarize labels in a one-vs-all fashion

                                                                                                                                              func NewLabelBinarizer32

                                                                                                                                              func NewLabelBinarizer32(NegLabel, PosLabel float32) *LabelBinarizer32

                                                                                                                                                NewLabelBinarizer32 ...

                                                                                                                                                func (*LabelBinarizer32) Fit

                                                                                                                                                func (m *LabelBinarizer32) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter

                                                                                                                                                  Fit for binarizer register classes

                                                                                                                                                  func (*LabelBinarizer32) FitTransform

                                                                                                                                                  func (m *LabelBinarizer32) FitTransform(X, Y mat.Matrix) (Xout, Yout General32)

                                                                                                                                                    FitTransform fit to data, then transform it

                                                                                                                                                    func (*LabelBinarizer32) InverseTransform

                                                                                                                                                    func (m *LabelBinarizer32) InverseTransform(X, Y General32) (Xout, Yout General32)

                                                                                                                                                      InverseTransform for LabelBinarizer32

                                                                                                                                                      func (*LabelBinarizer32) Transform

                                                                                                                                                      func (m *LabelBinarizer32) Transform(X, Y mat.Matrix) (Xout, Yout General32)

                                                                                                                                                        Transform for LabelBinarizer32

                                                                                                                                                        func (*LabelBinarizer32) TransformerClone

                                                                                                                                                        func (m *LabelBinarizer32) TransformerClone() *LabelBinarizer32

                                                                                                                                                          TransformerClone ...

                                                                                                                                                          type LabelBinarizer64

                                                                                                                                                          type LabelBinarizer64 struct {
                                                                                                                                                          	NegLabel, PosLabel float64
                                                                                                                                                          	Classes            [][]float64
                                                                                                                                                          }

                                                                                                                                                            LabelBinarizer64 Binarize labels in a one-vs-all fashion

                                                                                                                                                            func NewLabelBinarizer64

                                                                                                                                                            func NewLabelBinarizer64(NegLabel, PosLabel float64) *LabelBinarizer64

                                                                                                                                                              NewLabelBinarizer64 ...

                                                                                                                                                              func (*LabelBinarizer64) Fit

                                                                                                                                                              func (m *LabelBinarizer64) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter

                                                                                                                                                                Fit for binarizer register classes

                                                                                                                                                                func (*LabelBinarizer64) FitTransform

                                                                                                                                                                func (m *LabelBinarizer64) FitTransform(X, Y mat.Matrix) (Xout, Yout General64)

                                                                                                                                                                  FitTransform fit to data, then transform it

                                                                                                                                                                  func (*LabelBinarizer64) InverseTransform

                                                                                                                                                                  func (m *LabelBinarizer64) InverseTransform(X, Y General64) (Xout, Yout General64)

                                                                                                                                                                    InverseTransform for LabelBinarizer64

                                                                                                                                                                    func (*LabelBinarizer64) Transform

                                                                                                                                                                    func (m *LabelBinarizer64) Transform(X, Y mat.Matrix) (Xout, Yout General64)

                                                                                                                                                                      Transform for LabelBinarizer64

                                                                                                                                                                      func (*LabelBinarizer64) TransformerClone

                                                                                                                                                                      func (m *LabelBinarizer64) TransformerClone() *LabelBinarizer64

                                                                                                                                                                        TransformerClone ...

                                                                                                                                                                        type MLPClassifier

                                                                                                                                                                        type MLPClassifier struct{ BaseMultilayerPerceptron64 }

                                                                                                                                                                          MLPClassifier ...

                                                                                                                                                                          func NewMLPClassifier

                                                                                                                                                                          func NewMLPClassifier(hiddenLayerSizes []int, activation string, solver string, Alpha float64) *MLPClassifier

                                                                                                                                                                            NewMLPClassifier returns a *MLPClassifier with defaults activation is one of logistic,tanh,relu solver is on of agd,adagrad,rmsprop,adadelta,adam (one of the keys of base.Solvers) defaults to "adam" Alpha is the regularization parameter lossName is one of square,log,cross-entropy (one of the keys of lm.LossFunctions) defaults to "log"

                                                                                                                                                                            func (*MLPClassifier) Fit

                                                                                                                                                                            func (mlp *MLPClassifier) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter

                                                                                                                                                                              Fit ...

                                                                                                                                                                              Example (Breast_cancer)
                                                                                                                                                                              Output:
                                                                                                                                                                              
                                                                                                                                                                              ExplainedVarianceRatio 0.996 [0.443 0.190 0.094 0.066 0.055 0.040 0.023 0.016 0.014 0.012 0.010 0.009 0.008 0.005 0.003 0.003 0.002 0.002 0.002 0.001]
                                                                                                                                                                              20 components explain 99.50% of variance
                                                                                                                                                                              accuracy>0.999 ? true
                                                                                                                                                                              
                                                                                                                                                                              Example (Iris)
                                                                                                                                                                              Output:
                                                                                                                                                                              
                                                                                                                                                                              ok
                                                                                                                                                                              
                                                                                                                                                                              Example (Mnist)
                                                                                                                                                                              Output:
                                                                                                                                                                              
                                                                                                                                                                              ok
                                                                                                                                                                              

                                                                                                                                                                              func (*MLPClassifier) IsClassifier

                                                                                                                                                                              func (*MLPClassifier) IsClassifier() bool

                                                                                                                                                                                IsClassifier returns true for MLPClassifier

                                                                                                                                                                                func (*MLPClassifier) Predict

                                                                                                                                                                                func (mlp *MLPClassifier) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense

                                                                                                                                                                                  Predict return the forward result for MLPClassifier

                                                                                                                                                                                  Example (Mnist)
                                                                                                                                                                                  Output:
                                                                                                                                                                                  
                                                                                                                                                                                  Accuracy:97.52%
                                                                                                                                                                                  

                                                                                                                                                                                  func (*MLPClassifier) PredicterClone

                                                                                                                                                                                  func (mlp *MLPClassifier) PredicterClone() base.Predicter

                                                                                                                                                                                    PredicterClone returns an (possibly unfitted) copy of predicter

                                                                                                                                                                                    func (*MLPClassifier) Score

                                                                                                                                                                                    func (mlp *MLPClassifier) Score(Xmatrix, Ymatrix mat.Matrix) float64

                                                                                                                                                                                      Score for MLPClassifier computes accuracy score

                                                                                                                                                                                      type MLPRegressor

                                                                                                                                                                                      type MLPRegressor struct{ BaseMultilayerPerceptron64 }

                                                                                                                                                                                        MLPRegressor ...

                                                                                                                                                                                        func NewMLPRegressor

                                                                                                                                                                                        func NewMLPRegressor(hiddenLayerSizes []int, activation string, solver string, Alpha float64) *MLPRegressor

                                                                                                                                                                                          NewMLPRegressor returns a *MLPRegressor with defaults activation is one of identity,logistic,tanh,relu solver is on of sgd,adam defaults to "adam" Alpha is the regularization parameter

                                                                                                                                                                                          func (*MLPRegressor) Fit

                                                                                                                                                                                          func (mlp *MLPRegressor) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter

                                                                                                                                                                                            Fit ...

                                                                                                                                                                                            Example (Boston)
                                                                                                                                                                                            Output:
                                                                                                                                                                                            
                                                                                                                                                                                            true
                                                                                                                                                                                            

                                                                                                                                                                                            func (*MLPRegressor) IsClassifier

                                                                                                                                                                                            func (*MLPRegressor) IsClassifier() bool

                                                                                                                                                                                              IsClassifier returns false for MLPRegressor

                                                                                                                                                                                              func (*MLPRegressor) Predict

                                                                                                                                                                                              func (mlp *MLPRegressor) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense

                                                                                                                                                                                                Predict return the forward result

                                                                                                                                                                                                func (*MLPRegressor) PredictProbas

                                                                                                                                                                                                func (mlp *MLPRegressor) PredictProbas(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense

                                                                                                                                                                                                  PredictProbas return the probability estimate

                                                                                                                                                                                                  func (*MLPRegressor) PredicterClone

                                                                                                                                                                                                  func (mlp *MLPRegressor) PredicterClone() base.Predicter

                                                                                                                                                                                                    PredicterClone allow clone predicter for pipeline on model_selection

                                                                                                                                                                                                    func (*MLPRegressor) Score

                                                                                                                                                                                                    func (mlp *MLPRegressor) Score(X, Y mat.Matrix) float64

                                                                                                                                                                                                      Score for MLPRegressor returns R2Score

                                                                                                                                                                                                      type Matrix

                                                                                                                                                                                                      type Matrix = mat.Matrix

                                                                                                                                                                                                        Matrix interface (identical to gonum/mat one's)

                                                                                                                                                                                                        type Mutable

                                                                                                                                                                                                        type Mutable interface {
                                                                                                                                                                                                        	Set(i, j int, v float64)
                                                                                                                                                                                                        	Matrix
                                                                                                                                                                                                        }

                                                                                                                                                                                                          Mutable provide Set to set value at row,col

                                                                                                                                                                                                          type Optimizer32

                                                                                                                                                                                                          type Optimizer32 interface {
                                                                                                                                                                                                          	// contains filtered or unexported methods
                                                                                                                                                                                                          }

                                                                                                                                                                                                            Optimizer32 is an interface for stochastic optimizers

                                                                                                                                                                                                            type Optimizer64

                                                                                                                                                                                                            type Optimizer64 interface {
                                                                                                                                                                                                            	// contains filtered or unexported methods
                                                                                                                                                                                                            }

                                                                                                                                                                                                              Optimizer64 is an interface for stochastic optimizers

                                                                                                                                                                                                              type RawMatrixer32

                                                                                                                                                                                                              type RawMatrixer32 interface {
                                                                                                                                                                                                              	RawMatrix() blas32General
                                                                                                                                                                                                              }

                                                                                                                                                                                                                RawMatrixer32 provide access to blas matrix

                                                                                                                                                                                                                type RawMatrixer64

                                                                                                                                                                                                                type RawMatrixer64 interface {
                                                                                                                                                                                                                	RawMatrix() blas64General
                                                                                                                                                                                                                }

                                                                                                                                                                                                                  RawMatrixer64 provide access to blas matrix

                                                                                                                                                                                                                  type RawRowViewer

                                                                                                                                                                                                                  type RawRowViewer = RawRowViewer64

                                                                                                                                                                                                                    RawRowViewer returns row as a float slice

                                                                                                                                                                                                                    type RawRowViewer32

                                                                                                                                                                                                                    type RawRowViewer32 interface {
                                                                                                                                                                                                                    	RawRowView(i int) []float32
                                                                                                                                                                                                                    }

                                                                                                                                                                                                                      RawRowViewer32 returns row as a float slice

                                                                                                                                                                                                                      type RawRowViewer64

                                                                                                                                                                                                                      type RawRowViewer64 interface {
                                                                                                                                                                                                                      	RawRowView(i int) []float64
                                                                                                                                                                                                                      }

                                                                                                                                                                                                                        RawRowViewer64 returns row as a float slice

                                                                                                                                                                                                                        type RawRowViewerXX

                                                                                                                                                                                                                        type RawRowViewerXX = RawRowViewer32

                                                                                                                                                                                                                          RawRowViewerXX returns row as a float slice

                                                                                                                                                                                                                          type SGDOptimizer32

                                                                                                                                                                                                                          type SGDOptimizer32 struct {
                                                                                                                                                                                                                          	Params           []float32
                                                                                                                                                                                                                          	LearningRateInit float32
                                                                                                                                                                                                                          	LearningRate     float32
                                                                                                                                                                                                                          	PowerT           float32
                                                                                                                                                                                                                          	LRSchedule       string
                                                                                                                                                                                                                          	Momentum         float32
                                                                                                                                                                                                                          	Nesterov         bool
                                                                                                                                                                                                                          	// contains filtered or unexported fields
                                                                                                                                                                                                                          }

                                                                                                                                                                                                                            SGDOptimizer32 is the stochastic gradient descent optimizer

                                                                                                                                                                                                                            type SGDOptimizer64

                                                                                                                                                                                                                            type SGDOptimizer64 struct {
                                                                                                                                                                                                                            	Params           []float64
                                                                                                                                                                                                                            	LearningRateInit float64
                                                                                                                                                                                                                            	LearningRate     float64
                                                                                                                                                                                                                            	PowerT           float64
                                                                                                                                                                                                                            	LRSchedule       string
                                                                                                                                                                                                                            	Momentum         float64
                                                                                                                                                                                                                            	Nesterov         bool
                                                                                                                                                                                                                            	// contains filtered or unexported fields
                                                                                                                                                                                                                            }

                                                                                                                                                                                                                              SGDOptimizer64 is the stochastic gradient descent optimizer

                                                                                                                                                                                                                              type Slicer

                                                                                                                                                                                                                              type Slicer interface {
                                                                                                                                                                                                                              	Slice(i, j, k, l int) Matrix
                                                                                                                                                                                                                              }

                                                                                                                                                                                                                                Slicer provides Slice(startRow,endRow,startCol,endCol)