Documentation ¶
Index ¶
- type Layer
- type Loss
- type Model
- type Optimizer
- type OptimizerFactory
- type Sequential
- func (s *Sequential) Accuracy(y, t []*Tensor) float64
- func (s *Sequential) AddLayer(layer Layer)
- func (s *Sequential) Build(loss Loss, factory OptimizerFactory) error
- func (s *Sequential) Fit(x, t []*Tensor, epochs, batchSize int)
- func (s *Sequential) Layers() []Layer
- func (s *Sequential) Loss(y, t []*Tensor) float64
- func (s *Sequential) Predict(inputs []*Tensor) []*Tensor
- func (s *Sequential) Summary() string
- type Shape
- type Tensor
- func (t *Tensor) AddBroadCast(a float64) *Tensor
- func (t *Tensor) AddTensor(tensor *Tensor) *Tensor
- func (t *Tensor) BroadCast(f func(float64) float64) *Tensor
- func (t *Tensor) Clone() *Tensor
- func (t *Tensor) DivBroadCast(a float64) *Tensor
- func (t *Tensor) DivTensor(tensor *Tensor) *Tensor
- func (t *Tensor) Dot(tensor *Tensor) *Tensor
- func (t *Tensor) Exp() *Tensor
- func (t *Tensor) Get(at Shape) float64
- func (t *Tensor) Log() *Tensor
- func (t *Tensor) Max() float64
- func (t *Tensor) MaxIndex() int
- func (t *Tensor) MulBroadCast(a float64) *Tensor
- func (t *Tensor) MulTensor(tensor *Tensor) *Tensor
- func (t *Tensor) Rank() int
- func (t *Tensor) ReShape(shape Shape) *Tensor
- func (t *Tensor) Set(a float64, at Shape)
- func (t *Tensor) Shape() Shape
- func (t *Tensor) SubBroadCast(a float64) *Tensor
- func (t *Tensor) SubTensor(tensor *Tensor) *Tensor
- func (t *Tensor) Sum() float64
- func (t *Tensor) Transpose() *Tensor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Layer ¶
type Layer interface { InputShape() Shape OutputShape() Shape Init(inputShape Shape, factory OptimizerFactory) error Call(inputs []*Tensor) []*Tensor Forward(inputs []*Tensor) []*Tensor Backward(douts []*Tensor) []*Tensor Params() []*Tensor Update() }
Layer is a layer of neural network.
type Loss ¶
type Loss interface { Call(y, t []*Tensor) float64 Forward(y, t []*Tensor) float64 Backward() []*Tensor }
Loss is a loss function of a neural network.
type Model ¶
type Model interface { Layers() []Layer Fit(x, y []*Tensor, epochs, batchSize int) Predict([]*Tensor) []*Tensor Build(Loss) error }
Model is a neural network model.
type OptimizerFactory ¶
OptimizerFactory creates optimizer.
func MomentumSGD ¶
func MomentumSGD(lr, momentum float64) OptimizerFactory
MomentumSGD is an optimizer that add momentum to SGD
type Sequential ¶
type Sequential struct {
// contains filtered or unexported fields
}
Sequential is a model that stack of layers.
func NewSequential ¶
func NewSequential(inputShape Shape) *Sequential
NewSequential creates an instance of sequential model.
func (*Sequential) Accuracy ¶
func (s *Sequential) Accuracy(y, t []*Tensor) float64
Accuracy is accuracy of predicted value.
func (*Sequential) AddLayer ¶
func (s *Sequential) AddLayer(layer Layer)
AddLayer adds layer to model.
func (*Sequential) Build ¶
func (s *Sequential) Build(loss Loss, factory OptimizerFactory) error
Build builds a model by connecting the given layers.
func (*Sequential) Fit ¶
func (s *Sequential) Fit(x, t []*Tensor, epochs, batchSize int)
Fit fits the model to the given dataset.
func (*Sequential) Layers ¶
func (s *Sequential) Layers() []Layer
Layers returns layers that model has.
func (*Sequential) Loss ¶
func (s *Sequential) Loss(y, t []*Tensor) float64
Loss is loss of predicted value.
func (*Sequential) Predict ¶
func (s *Sequential) Predict(inputs []*Tensor) []*Tensor
Predict predicts output for the given data.
type Shape ¶
type Shape []int
Shape is a shape of a tensor.
type Tensor ¶
type Tensor struct {
// contains filtered or unexported fields
}
Tensor is an algebraic object that describes a relationship between sets of algebraic objects related to a vector space.
func TensorFromSlice ¶
TensorFromSlice creates an instance of tensor initialized with a given data.
func (*Tensor) AddBroadCast ¶
AddBroadCast adds a value to all elements.
func (*Tensor) BroadCast ¶
BroadCast creates a tensor of the return value that inputs all the elements into the passed function.
func (*Tensor) DivBroadCast ¶
DivBroadCast divides all elements by a value.
func (*Tensor) MulBroadCast ¶
MulBroadCast multiplies all elements by a value.
func (*Tensor) SubBroadCast ¶
SubBroadCast subtracts a valuefrom all elements.