November 2018
Beginner to intermediate
348 pages
8h 32m
English
A good question to ask is why? Why bother with this separation of processes? After all, the preceding code could be rewritten as the previous chapter's Predict function:
func (nn *NN) Predict(a tensor.Tensor) (int, error) { if a.Dims() != 1 { return nil, errors.New("Expected a vector") } var m maybe act0 := m.sigmoid(m.matVecMul(nn.hidden, a)) pred := m.sigmoid(m.matVecMul(nn.final, act0)) if m.err != nil { return -1, m.err } return argmax(pred.Data().([]float64)), nil}
Here, we define the network in Go, and when we run the Go code, the neural network is run as it is being defined. What's the problem we face that we need to introduce the idea of separating the definition of the neural network and running it? We've already seen the problem ...
Read now
Unlock full access