Categorygorgonia.org/gorgonia
modulepackage
0.9.18
Repository: https://github.com/gorgonia/gorgonia.git
Documentation: pkg.go.dev

# README

Logo

GoDoc GitHub version Build and Tests codecov Go Report Card unstable

Gorgonia is a library that helps facilitate machine learning in Go. Write and evaluate mathematical equations involving multidimensional arrays easily. If this sounds like Theano or TensorFlow, it's because the idea is quite similar. Specifically, the library is pretty low-level, like Theano, but has higher goals like Tensorflow.

Gorgonia:

  • Can perform automatic differentiation
  • Can perform symbolic differentiation
  • Can perform gradient descent optimizations
  • Can perform numerical stabilization
  • Provides a number of convenience functions to help create neural networks
  • Is fairly quick (comparable to Theano and TensorFlow speed)
  • Supports CUDA/GPGPU computation (OpenCL not yet supported, send a pull request)
  • Will support distributed computing

Goals

The primary goal for Gorgonia is to be a highly performant machine learning/graph computation-based library that can scale across multiple machines. It should bring the appeal of Go (simple compilation and deployment process) to the ML world. It's a long way from there currently, however, the baby steps are already there.

The secondary goal for Gorgonia is to provide a platform for the exploration of non-standard deep-learning and neural network-related things. This includes things like neo-hebbian learning, corner-cutting algorithms, evolutionary algorithms, and the like.

Why Use Gorgonia?

The main reason to use Gorgonia is developer comfort. If you're using a Go stack extensively, now you have access to the ability to create production-ready machine learning systems in an environment that you are already familiar with and comfortable with.

ML/AI at large is usually split into two stages: the experimental stage where one builds various models, tests, and retests; and the deployed state where a model after being tested and played with, is deployed. This necessitates different roles like data scientist and data engineer.

Typically the two phases have different tools: Python (PyTorch, etc) is commonly used for the experimental stage, and then the model is rewritten in some more performant language like C++ (using dlib, mlpack etc). Of course, nowadays the gap is closing and people frequently share the tools between them. Tensorflow is one such tool that bridges the gap.

Gorgonia aims to do the same but for the Go environment. Gorgonia is currently fairly performant - its speeds are comparable to PyTorch's and Tensorflow's CPU implementations. GPU implementations are a bit finicky to compare due to the heavy CGO tax, but rest assured that this is an area of active improvement.

Getting started

Installation

The package is go-gettable: go get -u gorgonia.org/gorgonia.

Gorgonia is compatible with Go modules.

Documentation

Up-to-date documentation, references, and tutorials are present on the official Gorgonia website at https://gorgonia.org.

Keeping Updated

Gorgonia's project has a Slack channel on gopherslack, as well as a Twitter account. Official updates and announcements will be posted to those two sites.

Usage

Gorgonia works by creating a computation graph and then executing it. Think of it as a programming language, but is limited to mathematical functions, and has no branching capability (no if/then or loops). In fact, this is the dominant paradigm that the user should be used to thinking about. The computation graph is an AST.

Microsoft's CNTK, with its BrainScript, is perhaps the best at exemplifying the idea that building a computation graph and running the computation graphs are different things and that the user should be in different modes of thought when going about them.

Whilst Gorgonia's implementation doesn't enforce the separation of thought as far as CNTK's BrainScript does, the syntax does help a little bit.

Here's an example - say you want to define a math expression z = x + y. Here's how you'd do it:

package gorgonia_test

import (
	"fmt"
	"log"

	. "gorgonia.org/gorgonia"
)

// Basic example of representing mathematical equations as graphs.
//
// In this example, we want to represent the following equation
//		z = x + y
func Example_basic() {
	g := NewGraph()

	var x, y, z *Node
	var err error

	// define the expression
	x = NewScalar(g, Float64, WithName("x"))
	y = NewScalar(g, Float64, WithName("y"))
	if z, err = Add(x, y); err != nil {
		log.Fatal(err)
	}

	// create a VM to run the program on
	machine := NewTapeMachine(g)
	defer machine.Close()

	// set initial values then run
	Let(x, 2.0)
	Let(y, 2.5)
	if err = machine.RunAll(); err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%v", z.Value())
	// Output: 4.5
}

You might note that it's a little more verbose than other packages of similar nature. For example, instead of compiling to a callable function, Gorgonia specifically compiles into a *program which requires a *TapeMachine to run. It also requires manual a Let(...) call.

The author would like to contend that this is a Good Thing - to shift one's thinking to machine-based thinking. It helps a lot in figuring out where things might go wrong.

Additionally, there is no support for branching - that is to say, there are no conditionals (if/else) or loops. The aim is not to build a Turing-complete computer.


More examples are present in the example subfolder of the project, and step-by-step tutorials are present on the main website

Using CUDA

Gorgonia comes with CUDA support out of the box. Please see the reference documentation about how cuda works on the Gorgonia.org website, or jump to the tutorial.

About Gorgonia's development process

Versioning

We use semver 2.0.0 for our versioning. Before 1.0, Gorgonia's APIs are expected to change quite a bit. API is defined by the exported functions, variables, and methods. For the developers' sanity, there are minor differences to SemVer that we will apply before version 1.0. They are enumerated below:

  • The MINOR number will be incremented every time there is a deleterious break in API. This means any deletion or any change in function signature or interface methods will lead to a change in the MINOR number.
  • Additive changes will NOT change the MINOR version number before version 1.0. This means that if new functionality were added that does not break the way you use Gorgonia, there would not be an increment in the MINOR version. There will be an increment in the PATCH version.

API Stability

Gorgonia's API is as of right now, not considered stable. It will be stable from version 1.0 forward.

Go Version Support

Gorgonia supports 2 versions below the Master branch of Go. This means Gorgonia will support the current released version of Go, and up to 4 previous versions - providing something doesn't break. Where possible a shim will be provided (for things like new sort APIs or math/bits which came out in Go 1.9).

The current version of Go is 1.13.1. The earliest version Gorgonia supports is Go 1.11.x but Gonum supports only 1.12+. Therefore, the minimum Go version to run the master branch is Go > 1.12.

Hardware and OS supported

Gorgonia runs on :

  • linux/AMD64
  • linux/ARM7
  • linux/ARM64
  • win32/AMD64
  • darwin/AMD64
  • freeBSD/AMD64

If you have tested Gorgonia on other platforms, please update this list.

Hardware acceleration

Gorgonia uses some pure assembler instructions to accelerate some mathematical operations. Unfortunately, only amd64 is supported.

Contributing

Obviously, since you are most probably reading this on Github, Github will form the major part of the workflow for contributing to this package.

See also: CONTRIBUTING.md

Contributors and Significant Contributors

All contributions are welcome. However, there is a new class of contributors, called Significant Contributors.

A Significant Contributor has shown a deep understanding of how the library works and/or its environs. Here are examples of what constitutes a Significant Contribution:

  • Wrote significant amounts of documentation on why/the mechanics of particular functions/methods and how the different parts affect one another
  • Wrote code and tests around the more intricately connected parts of Gorgonia
  • Wrote code and tests, and had at least 5 pull requests accepted
  • Provided expert analysis on parts of the package (for example, you may be a floating point operations expert who optimized one function)
  • Answered at least 10 support questions.

The significant Contributors list will be updated once a month (if anyone even uses Gorgonia that is).

How To Get Support

The best way of support right now is to open a ticket on Github.

Frequently Asked Questions

Why are there seemingly random runtime.GC() calls in the tests?

The answer to this is simple - the design of the package uses CUDA in a particular way: specifically, a CUDA device and context are tied to a VM, instead of at the package level. This means for every VM created, a different CUDA context is created per device per VM. This way all the operations will play nicely with other applications that may be using CUDA (this needs to be stress-tested, however).

The CUDA contexts are only destroyed when the VM gets garbage collected (with the help of a finalizer function). In the tests, about 100 VMs get created, and garbage collection for the most part can be considered random. This leads to cases where the GPU runs out of memory as there are too many contexts being used.

Therefore at the end of any tests that may use GPU, a runtime.GC() call is made to force garbage collection, freeing GPU memories.

In production, one is unlikely to start that many VMs, therefore it's not a problem. If there is, open a ticket on GitHub, and we'll look into adding a Finish() method for the VMs.

Licence

Gorgonia is licensed under a variant of Apache 2.0. It's the same as the Apache 2.0 Licence, except not being able to commercially profit directly from the package unless you're a Significant Contributor (for example, providing commercial support for the package). It's perfectly fine to profit directly from a derivative of Gorgonia (for example, if you use Gorgonia as a library in your product)

Everyone is still allowed to use Gorgonia for commercial purposes (for example: using it in software for your business).

Dependencies

There are very few dependencies that Gorgonia uses - and they're all pretty stable, so as of now there isn't a need for vendoring tools. These are the list of external packages that Gorgonia calls, ranked in order of reliance that this package has (sub-packages are omitted):

PackageUsed ForVitalityNotesLicence
gonum/graphSorting *ExprGraphVital. Removal means Gorgonia will not workDevelopment of Gorgonia is committed to keeping up with the most updated versiongonum license (MIT/BSD-like)
gonum/blasTensor subpackage linear algebra operationsVital. Removal means Gorgonial will not workDevelopment of Gorgonia is committed to keeping up with the most updated versiongonum license (MIT/BSD-like)
cuCUDA driversNeeded for CUDA operationsSame maintainer as GorgoniaMIT/BSD-like
math32float32 operationsCan be replaced by float32(math.XXX(float64(x)))Same maintainer as Gorgonia, same API as the built-in math packageMIT/BSD-like
hmType system for GorgoniaGorgonia's graphs are pretty tightly coupled with the type systemSame maintainer as GorgoniaMIT/BSD-like
vecf64optimized []float64 operationsCan be generated in the tensor/genlib package. However, plenty of optimizations have been made/will be madeSame maintainer as GorgoniaMIT/BSD-like
vecf32optimized []float32 operationsCan be generated in the tensor/genlib package. However, plenty of optimizations have been made/will be madeSame maintainer as GorgoniaMIT/BSD-like
setVarious set operationsCan be easily replacedStable API for the past 1 yearset licence (MIT/BSD-like)
gographvizUsed for printing graphsGraph printing is only vital to debugging. Gorgonia can survive without, but with a major (but arguably nonvital) feature lossLast update 12th April 2017gographviz license (Apache 2.0)
rngUsed to implement helper functions to generate initial weightsCan be replaced fairly easily. Gorgonia can do without the convenience functions toorng license (Apache 2.0)
errorsError wrappingGorgonia won't die without it. In fact Gorgonia has also used goerrors/errors in the past.Stable API for the past 6 monthserrors licence (MIT/BSD-like)
gonum/matCompatibility between Tensor and Gonum's MatrixDevelopment of Gorgonia is committed to keeping up with the most updated versiongonum license (MIT/BSD-like)
testify/assertTestingCan do without but will be a massive pain in the ass to testtestify license (MIT/BSD-like)

Various Other Copyright Notices

These are the packages and libraries that inspired and were adapted from in the process of writing Gorgonia (the Go packages that were used were already declared above):

SourceHow it's UsedLicence
NumpyInspired large portions. Directly adapted algorithms for a few methods (explicitly labeled in the docs)MIT/BSD-like. Numpy Licence
TheanoInspired large portions. (Unsure: number of directly adapted algorithms)MIT/BSD-like Theano's license
Caffeim2col and col2im directly taken from Caffe. Convolution algorithms inspired by the original Caffee methodsCaffe Licence

# Packages

# Functions

Abs performs a pointwise abs.
Add performs a pointwise add operation.
ApplyOp is the generic function application - for when no specialization is required.
ApplyOpWithName applies the op, and then gives the node the given name.
At is a symbolic operation for getting a value at the provided coordinates.
Auto automatically calculates the padding for the given operations, for example: gorgonia.Auto(gorgonia.BroadcastHadamardProd, a, b).
AveragePool1D applies a average pool on the node x.
AveragePool2D applies the average operation to the given input.
Backpropagate backpropagates errors by performing reverse-mode symbolic differentiation, starting from the outputs, and working its way towads the inputs.
BatchedMatMul returns a node representing the batched mat mul operation.
BatchNorm applies a batchnormalization.
BinaryXent is a convenience function for doing binary crossentropy stuff.
BindDualValues is an option for *tapeMachine only.
Binomial32 returns a []float32 drawn from a binomial distribution given the trial and probability parameters.
Binomial64 returns a []float64 drawn from a binomial distribution given the trial and probability parameters.
BinomialRandomNode creates an input node that has a random op so that everytime the node is passed, random values will be plucked from a binomial distribution with the mean and stdev provided.
Broadcast apply the pattern to the input nodes and returns two nodes suitable for a binary operator.
Add performs a add.
Eq performs a eq.
Gt performs a gt.
Gte performs a gte.
HadamardDiv performs a hadamarddiv.
HadamardProd performs a hadamardprod.
Lt performs a lt.
Lte performs a lte.
Ne performs a ne.
Pow performs a pow.
Sub performs a sub.
ByIndices is an operation that takes the indices as input and return the selected values from those indices.
Ceil performs a pointwise ceil.
CheckOne checks whether an input is an error.
CloneValue clones a value.
Compile takes a graph and outputs a program suitable for *tapeMachine to run.
CompileFunction takes a graph, subsets it based on the input and output nodes provided and outputs a program suitable for *tapeMachine to run.
Concat performs a concatenate on the provided axis and inputs.
Conv1d is a 1D convlution.
Conv2d is a simple 2D convolution, to be used for CPU computation only.
ConvType converts the type of the x Node from one type to other.
Copy copies the src values into dest values.
Cos performs a pointwise cos.
CTCLoss - implements the ctc loss operation This is the implementation of the following paper: http://www.cs.toronto.edu/~graves/icml_2006.pdf.
Cube performs a pointwise cube.
DebugDerives turns on the derivation debug option when printing a graph.
DiagFlat takes the flattened value and creates a diagonal matrix from it.
DimSizersToShapes is a convenience function to convert a slice of DimSizer to a slice of tensor.Shape.
Div is a shortcut function for HadamardDiv for scalar values.
DontDebugDerives turns off derivation debug option when printing a graph.
Dropout is a convenience function to implement dropout.
Eq performs a pointwise eq operation.
Err is a function that returns a gErr.
EvalMode enables the eval mode for the VM and graph.
ExecuteBwdOnly creates a VM that will execute a graph by doing back propagation only.
ExecuteFwdOnly creates a VM that will execute a graph forwards only - it will not do back propagation.
Exp performs a pointwise exp.
Expm1 performs a pointwise expm1.
Floor performs a pointwise floor.
FmtNodeMap is a convenience function to print map[*Node]<T> The fmt flag that makes it all nicely formatted is "-".
Gaussian creates a InitWFn with the specified parameters.
Gaussian32 returns a []float32 drawn from a gaussian distribution as defined by the mean and stdev.
Gaussian64 returns a []float64 drawn from a gaussian distribution as defined by the mean and stdev.
GaussianRandomNode creates an input node that has a random op so everytime the node is passed, random values will be plucked from a gaussian distribution with the mean and stdev provided.
GlobalAveragePool2D consumes an input tensor X and applies average pooling across the values in the same channel.
GlorotEtAlN32 returns float32 weights sampled from a normal distribution using the methods specified in Glorot et.
GlorotEtAlN64 returns float64 weights sampled from a normal distribution using the methods specified in Glorot et.
GlorotEtAlU32 returns float32 weights sampled from a uniform distribution using the methods specified in Glorot et.
GlorotEtAlU64 returns float64 weights sampled from a uniform distribution using the methods specified in Glorot et.
GlorotN creates a InitWFn that populates a Value with weights normally sampled using Glorot et al.'s algorithm.
GlorotU creates a InitWFn that populates a Value with weights uniformly sampled using Glorot et al.'s algorithm.
Grad takes a scalar cost node and a list of with-regards-to, and returns the gradient.
GraphCollisionStats returns the collisions in the graph only when built with the debug tag, otherwise it's a noop that returns 0.
Gt performs a pointwise gt operation.
Gte performs a pointwise gte operation.
HadamardDiv performs a pointwise hadamarddiv operation.
HadamardProd performs a pointwise hadamardprod operation.
HeEtAlN64 returns float64 weights sampled from a normal distro, using the methods described in He et al (2015).
HeEtAlU64 returns float64 weights sampled from a uniform distro, using the methods described in He et al (2015).
Im2Col converts a BCHW image block to columns.
In is a node construction option to set a node's graph.
Inverse performs a pointwise inverse.
InverseSqrt performs a pointwise inversesqrt.
KeepDims is a function that ensures that input and output dimensions are the same though the shape may change.
LeakyRelu returns a node whose underlying value is: f(x) = alpha * x if x < 0 f(x) = x for x ⩾ 0 applied elementwise.
Let binds a Value to a node that is a variable.
Lift1 decorates a function with a precheck and post function lifting.
Lift1Axial decorates a function with a precheck and post function lifting.
Lift2 decorates a function with a precheck and post function lifting.
Lift2Broadcast decorates a function with a precheck and post function lifting.
LiftResult creates a Result from a Input and error pair.
Log performs a pointwise log.
Log1p performs a pointwise log1p.
Log2 performs a pointwise log2.
LogBothDir logs both directions of the execution of the graph.
LogBwd logs the backwards execution of a graph.
LogFwd logs the forward execution of a graph.
Applies LogSoftMax to the input x.
LogSumExp performs addition in the log domain.
Lt performs a pointwise lt operation.
Lte performs a pointwise lte operation.
Max performs a max() on the input and the provided axes.
MaxPool1D applies a maxpool on the node x.
MaxPool2D applies the kernel filter to the input node.
Mean performs a mean() on the input and the provided axes.
Mish is a novel activation function that is self regularizing.
Mul is the general handler for multiplication of nodes.
Must indicates a node must be created.
Ne performs a pointwise ne operation.
Neg performs a pointwise neg.
NewAdaGradSolver creates a new AdaGradSolver with sane-ish default values.
NewAdamSolver creates an Adam solver with these default values: eta (learn rate) : 0.001 eps (smoothing factor) : 1e-8 beta1 : 0.9 beta2 : 0.999 batch : 1.
NewAddOp creates a new *ExternalOp that wraps an add op.
NewBarzilaiBorweinSolver creates a new Barzilai-Borwein solver withs some default values: the learn rate is set to 0.001 and the solver does not use clipping.
NewBroadcastPattern is a helper function to create broadcast patterns.
NewConstant takes in any reasonable value and makes it a constant node.
NewExternalOp creates a new *ExternalOp.
NewGraph creates a new graph.
NewHadamardProdOp creates a new *ExternalOp that wraps a mul op.
NewLispMachine creates a VM that executes the graph as it is traversed.
NewMatrix creates a Node representing a variable that holds a matrix (nxm).
NewMomentum creates a new Momentum with sane-ish default values.
NewNodeSet creates and returns a reference to an empty set.
NewRMSPropSolver creates an RMSProp solver with these default values: eta (learn rate) : 0.001 eps (smoothing factor): 1e-8 rho (decay factor) : 0.999.
NewScalar creates a Node representing a variable that holds a scalar value.
NewSubOp creates a new *ExternalOp that wraps a sub op.
NewTapeMachine creates a VM that compiles a graph into a prog.
NewTensor creates a Node representing a variable that holds a tensor (any n-dimensional array with dimensions greater than 2).
NewUniqueNode creates a new unique node in a graph.
NewVanillaSolver creates a new VanillaSolver with sane-ish default values.
NewVector creates a Node representing a variable that holds a vector (nx1 matrix).
NodeFromAny creates a Node from a tensor.Tensor, automatically filling in shape and type info.
NodesFromInputs creates a Nodes from a list of Input.
NodesToValueGrads is a utility function that converts a Nodes to a slice of ValueGrad for the solvers.
Norm returns the p-norm of a Value.
OneHotVector creates a node representing a one hot vector.
Ones creates an InitWfn that populates a Value with ones.
OuterProd returns a Node representing the outer product of two vectors.
Pow performs a pointwise pow operation.
RangedFrom creates an InitWFn that populates a Value starting with the provided start, increamenting the number for each element in the value by 1.
RangedFromWithStep creates an InitWFn that populates a value starting with the provided start, and incrementing the number for each element by the provided increment.
Ravel flattens the given node and returns the new node.
Read allows for extraction of the value of the *Node at runtime into a Value.
Rectify is a convenience function for creating rectified linear units activation functions.
ReduceAdd takes a slice of *Nodes, and folds them into one by adding.
ReduceMul is like foldl(*, nodes).
Reshape reshapes a node and returns a new node with the new shape.
ReturnNode returns a node to the pool.
ReturnType ...
S creates a tensor.Slice.
ScalarAsTensor returns the tensor representation of a scalar.
Set is the equivalent of doing this: a = b where a and b are both variables.
SetDerivOf is used to hack around the fundamental limitations of Gorgonia.
SetOptimizationLevel sets the fast math optimization level.
ShapesToDimSizers is a convenience function to convert a slice of tensor.Shape to a slice of DimSizer.
Sigmoid performs a pointwise sigmoid.
Sign performs a pointwise sign.
Sin performs a pointwise sin.
SizeOf returns the size of a value along an axis.
Slice slices a *Node.
Applies SoftMax to the input x.
Softplus performs a pointwise softplus.
Sort topologically sorts a ExprGraph: root of graph will be first nodes are sorted using gonum's SortStabilized function.
Sparsemax - implements the sparsemax operation described here: http://proceedings.mlr.press/v48/martins16.pdf.
Sqrt performs a pointwise sqrt.
Square performs a pointwise square.
Sub performs a pointwise sub operation.
Sum performs a sum() on the input and the provided axes.
Tanh performs a pointwise tanh.
Tensordot performs a tensor contraction of a and b along specified axes.
TraceExec is an option for *tapeMachine only.
TransformResult is like LiftResult, but allows for custom data types that fulfil Mker.
Transpose performs a transpose on the input and provided permutation axes.
TypeOf returns the Type of the value.
Unconcat is the opposite of the built in concat function TODO: port this back to Gorgonia and use Gorgonia's sli instead.
Uniform creates a InitWFn with the specified parameters.
Uniform32 returns a []float64 drawn from a uniform distribution between [low, high) that is provided.
Uniform64 returns a []float64 drawn from a uniform distribution between [low, high) that is provided.
UniformRandomNode creates an input node that has a random op so everytime the node is passed, random values will be plucked from a uniform distribution.
UnsafeLet binds a Value to any node, not just a variable node.
UnstableSort performs a topological sort of the directed graph g returning the 'from' to 'to' sort order.
Upsample2D - simply upscaling Tensor by scale factor.
Use defines which BLAS implementation gorgonia should use.
UseCudaFor is an option for *tapeMachine.
UseNonStable turns off the stabilization functions when building graphs.
UseStabilization sets the global option to invoke stabilization functions when building the graph.
ValueClose checks whether two values are close to one another.
ValueEq is the equality function for values.
ValuesOf creates an InitWrn that populates a value with val.
WalkGraph walks a graph.
WhichBLAS returns the BLAS that gorgonia uses.
WithBatchSize sets the batch size for the solver.
WithBeta1 sets the beta1 param of the solver.
WithBeta2 sets the beta1 param of the solver.
WithChildren sets the children of a node to the specified chidren.
WithClip clips the gradient if it gets too crazy.
WithEngine sets the tensor engine for computation inside the VM.
WithEps sets the smoothing factor for the solver.
WithGrad is a node construction option that binds the value to the *Node.
WithGraphName is a ExprGraph construction option that provides a name.
WithGroupName is a node construction option to group a *Node within a particular group.
WithInfWatch creates a VM that will watch for Infs when executing.
WithInit is a node construction option to initialize a *Node with the InitWFn provided.
WithL1Reg adds a L1 regularization parameter to the solver.
WithL2Reg adds a L2 regularization parameter to the solver.
WithLearnRate sets the learn rate or step size for the solver.
WithLogger creates a VM with the supplied logger.
WithManualGradient allows the user to set the gradient of the root, before backprop.
WithMomentum sets the momentum of the solver.
WithName is a node construction option that gives the *Node the provided name.
WithNaNWatch creates a VM that will watch for NaNs when executing.
WithOp is a node construction option to set a node's Op to the specified Op.
WithPointerWatch creates a VM that will watch for pointer clashes when executing.
WithPrecompiled is an option to pass in compiled programs.
WithRho sets the decay parameter of the RMSProp solver.
WithShape is a node construction option to initialize a *Node with a particular shape.
WithType is a node construction option to set a node to the specified type.
WithValue is a node construction option that binds the value to the *Node.
WithValueFmt defines how the logger will output the values.
WithWatchlist creates a VM with a watchlist.
YOLOv3 https://arxiv.org/abs/1804.02767.
Zeroes creates an InitWfn that populates a Value with..
ZeroValue returns the zero value of a type.

# Constants

CPU the only device the graph will be executed on.
CUDA indicates if this build is using CUDA.
DEBUG indicates if this build is in debug mode.

# Variables

āBinOpStrs is the string representation for binLAOperator It should be held constant.
Bool ...
Byte ...
Float32 ...
Float64 ...
Int ...
Int32 ...
Int64 ...
Ptr is equivalent to interface{}.
ʘBinOpCommutative is the array that stores whether a binary operator is commutative It should be held constant.
ʘBinOpNames is the string representation for a binOpType It should be held constant.
ʘBinOpStrs is the string representation for a binOpType It should be held constant.
ʘUnaryOpDifferentiable is the array of whether a unary operator is differentiable It should be held constant.
ʘUnaryOpStrs is the string representation for a unaryOpType It should be held constant.

# Structs

AdaGradSolver is the solver that does adaptive gradient descent.
AdamSolver is the Adaptive Moment Estimation solver (basically RMSProp on steroids).
AdamW is a Adam-like solver where the weight decay regularization is decoupled.
AutoDiffError is an error which should be passed if the function is not differentiable.
BarzilaiBorweinSolver / Barzilai-Borwein performs Gradient Descent in steepest descend direction Solves 0 = F(x), by xᵢ₊₁ = xᵢ - eta * Grad(F)(xᵢ) Where the learn rate eta is calculated by the Barzilai-Borwein method: eta(xᵢ) = <(xᵢ - xᵢ₋₁), (Grad(F)(xᵢ) - Grad(F)(xᵢ₋₁))> / ∥(Grad(F)(xᵢ) - Grad(F)(xᵢ₋₁))∥² The input learn rate is used for the first iteration.
BatchNormOp is a batch normalization process as described by Ioffe and Szegedy (2015) - http://arxiv.org/abs/1502.03167 Normalization is done as: γ(x - μ) / σ + β γ is the scaling factor and β is the offset factor.
ExecutionContext informs how an op should be executed.
ExprGraph is a data structure for a directed acyclic graph (of expressions).
ExternalOp is an op that contains an external context.
ExternMetadata is used to hold metadata about external execution devices.
Momentum is the stochastic gradient descent optimizer with momentum item.
A Node is a node in the computation graph.
RMSPropSolver is a solver that implements Geoffrey Hinton's RMSProp gradient descent optimization algorithm.
StandardEngine is the default CPU engine for gorgonia.
SymDiffError provides the context at which an error occurred.
TensorType is a type constructor for tensors.
VanillaSolver is your bog standard stochastic gradient descent optimizer.

# Interfaces

An ADOp is an Op that supports automatic differentiation.
Arena is a representation of a pool of tensor.Memory.
Batched interface describes any object that can process batch work.
BatchedBLAS interface describes any object that can process BLAS work in batch.
BatchedDevice is the superset of BatchedBLAS and the batched CUDA workflow.
A BinaryOp is an Op that takes only two inputs.
BLAS represents all the possible implementations of BLAS.
CLDoer uses OpenCL to perform the Op.
CloneErrorer represents any type that can clone itself and return an error if necessary.
Cloner represents any type that can clone itself.
CopierFrom represents any type that can copy data from the source provided.
CopierTo represents any type that can copy data to the destination.
A CUDAADOp operation have a specific method to run with CUDA.
CUDADoer uses CUDA to perform the Op.
DimSizer is any type (typically a tensor.Shape) that allows querying for a dimension size given an input dimension.
Dtyper represents any type (typically a Value) that knows its own Dtype.
Errer is an interface that can return an error.
External is a representation of an external device (cuda/cgo/openCL), conceptually modelled as a machine.
IncrDoer increments the toIncr with the result of doing.
Input is something that can produce both a *Node and Nodes.
Mker is an interface of any Input that can make a new version of itself.
Namer is anything that has a name.
NoOpError is an error returned when an operation does nothing.
A NoRetOp is an Op that reads a value, but does not return any value.
An Op is a symbolic representation of an operation Think of them as functions, taking an input (or multiple), and outputting something All Ops have type signatures that look like this: OpName :: (Floats a) ⇒ Tensor a → Tensor a → Tensor a.
ReductionOp changes the shape of the node.
Result is either a Node or Nodes or error.
Scalar represents a scalar(non-array-based) value.
A SDOp is an Op that supports symbolic differentiation.
Solver is anything that does gradient updates.
Tensor is an interface that describes an ndarray.
A TrainModeOp is an Op that supports modes to enable/disable training.
Typer represents any type (typically a Op) that knows its own Type.
A UnaryOp is an Op that takes only one input.
UnsafeDoer is an op that will overwrite the underlying value.
UsePreallocDoer is an op that works when a preallocated value is provided.
Value represents a value that Gorgonia accepts.
ValueCloser represents any type that can perform a close-value check.
ValueEqualer represents any type that can perform a equal value check.
ValueGrad is any type that has a value and a grad.
Valuer is any type that can return a Value.
VM represents a structure that can execute a graph or program.
Zeroer is a Value that can zero itself.
ZeroValuer is a a Value that can provide the zero-value of its type.
a ʘUnaryOperator is essentially a function that takes a float32 or float64 and returns the same pros : no overloading = clear understanding cons : no overloading = a lot of extra code There are TWO ʘUnaryOperator types so far: sf32UnaryOperator - scalar float32 unary operator sf64UnaryOperator - scalar float64 unary operator Because TensorTypes are parameterized by a scalar type, it isn't necessary to create operators that will work on TensorTypes.

# Type aliases

B represents a bool value.
BroadcastPattern is actually a bit array.
Device represents the device where the code will be executed on.
F32 represents a float32 value.
F64 represents a float64 value.
I represents a int value.
I32 represents a int32 value.
I64 represents a int64 value.
InitWFn is a type of helper function to help initialize weights vector/matrices.
NodeConsOpt is a function that provides construction options for any Node.
NodeID represents the ID of a node.
Nodes is a slice of nodes, but it also acts as a set of nodes by implementing the Sort interface.
NodeSet is the primary type that represents a set.
SolverOpt is a function that provides construction options for a Solver.
U8 represents a byte value.
VMOpt is a VM creation option.