liveBook · Manning

Training dataset

As explained in Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

A collection of examples or observations supplied to a learning procedure to fit or adapt a model or learn its patterns or parameters.

A training dataset pairs inputs with expected outputs. A neural network uses each pair to calculate error, backpropagate it, and update its weights. section 7.5

One training pass

For each input array, the network computes outputs, compares them with the corresponding expected-output array, then updates its weights. section 7.5

    /// train() uses the results of outputs() run over
    /// many *inputs* and compared against *expecteds* to feed
    /// backpropagate() and updateWeights()
    func train(inputs: [[Double]], expecteds: [[Double]], printError: Bool =
     false, threshold: Double? = nil) {
        for (location, xs) in inputs.enumerated() {
            let ys = expecteds[location]
            let outs = outputs(input: xs)
            if (printError) {
                let diff = sub(outs, ys)
                let error = sqrt(sum(mul(diff, diff)))
                print("\(error) error in run \(location)")
            }
            backpropagate(expected: ys)
            updateWeights()
        }
    }

The train() implementation shows how input and expected-output arrays drive forward passes, error reporting, backpropagation, and weight updates. section 7.5

How Classic Computer Science Problems in Swift: Essential techniques for practicing programmers covers it

How deep it goes
Defines paired examples and details forward passes, backpropagation, and weight updates; treats validation separately.
Examples
Uses arrays of input vectors and expected-output vectors, with optional per-run error reporting.
What you can do after
Apply it through train() to update network weights from input and expected-output arrays.
How it connects
Connects neural-network training to backpropagation, gradient descent, and validation.

Also explained in

Compare how 36 books explain training dataset →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Computer Science Problems in Swift: Essential techniques for practicing programmers. The section links point to the parts of the book it draws on.