A set of numeric libraries for the Go programming language

The most feature-complete library that could potentially be useful for DL (aside from Gorgonia, which we will cover in later sections) is Gonum. The simplest description would be that Gonum attempts to emulate much of the functionality of the well-known scientific computing libraries in Python, namely, NumPy and SciPy.

Let's take a look at a code example for constructing a matrix we might use to represent inputs to a DNN.

Initialize a matrix and back it with some numbers, as follows:

// Initialize a matrix of zeros with 3 rows and 4 columns.
d := mat.NewDense(3, 4, nil)
fmt.Printf("%v ", mat.Formatted(d))
// Initialize a matrix with pre-allocated data. Data has row-major storage.
data := []float64{
6, 3, 5,
-1, 9, 7,
2, 3, 4,}
d2 := mat.NewDense(3, 3, data)
fmt.Printf("%v ", mat.Formatted(d2))

Perform operations on the matrix, as shown in the following code:

a := mat.NewDense(2, 3, []float64{
3, 4, 5,
1, 2, 3,
})

b := mat.NewDense(3, 3, []float64{ 1, 1, 8,
1, 2, -3,
5, 5, 7,
})
fmt.Println("tr(b) =", mat.Trace(b))

c := mat.Dense{}
c.Mul(a, b)
c.Add(c, a)
c.Mul(c, b.T())
fmt.Printf("%v ", mat.Formatted(c))

Here, we can see that Gonum offers us the primitives we need to manipulate the matrices exchanged between layers in DNNs, namely, c.Mul and c.Add.

When we decide to scale up our design ambitions, this is when we run into the limitations of Gonum. There are no GRU/LSTM cells and there is no SGD with backpropagation. If we are to reliably and efficiently construct DNNs that we want to carry all of the way through to production, we need to look elsewhere for a more complete library.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset