- Learn
- Computer Science & IT
- Computer Science
- Artificial Intelligence
- Supervised Learning and Neural Networks
Supervised Learning and Neural Networks: Classifiers
IntermediateLesson 9 of 10 in Artificial Intelligence Course
What you will learn
- Describe what a learning program receives, what it produces and how its quality is measured: labeled examples, features, hypotheses, loss and performance on new data.
- Describe the supervised learning taskName the parts of a supervised learning problem, tell classification from regression, and explain why a learned hypothesis is judged on examples it has not seen.
- Represent examples with features and measure lossTurn inputs into feature vectors, compute weighted scores with a dot product, and measure a hypothesis's mistakes with a loss function.
- Describe the supervised learning task
- Build a probabilistic classifier from Bayes' rule and a conditional independence assumption, estimate its probabilities by counting with smoothing, and apply it to text.
- Make predictions with the naive Bayes modelState the naive Bayes assumption, compute class scores and posterior probabilities for an example, and carry out the computation with logarithms.
- Estimate naive Bayes probabilities from dataEstimate the prior and conditional probabilities by counting, see why a zero count breaks the model, and repair it with Laplace smoothing.
- Classify text with a bag-of-words modelRepresent documents by word counts, classify them with multinomial naive Bayes in log space, and recognize what the model ignores.
- Make predictions with the naive Bayes model
- Separate classes with a weighted sum of features, learn the weights with the perceptron rule, and turn scores into probabilities with logistic regression.
- Read linear decision boundariesCompute a linear classifier's score and prediction, describe its decision boundary, and decide whether a data set is linearly separable.
- Learn weights with the perceptron ruleRun the perceptron learning rule by hand, explain when it converges and what happens when it cannot, and extend it to several classes.
- Predict probabilities with logistic regressionUse the sigmoid to turn a linear score into a probability, interpret the weights as changes in log-odds, measure fit with log loss, and extend the model to many classes with softmax.
- Read linear decision boundaries
- Treat training as minimizing a loss, compute gradients, choose a learning rate, and train models with stochastic and mini-batch gradient descent.
- Minimize a loss by following the gradientCompute partial derivatives and gradients, apply the gradient descent update by hand, and see how the learning rate and the shape of the loss affect the result.
- Train with stochastic and mini-batch gradient descentCompare batch, stochastic and mini-batch gradient descent, derive and apply the logistic regression update, and relate it to the perceptron rule.
- Minimize a loss by following the gradient
- Compute the output of a feedforward network, find every weight's gradient with backpropagation, and train networks in practice.
- Compute the output of a feedforward networkDescribe units, activation functions and layers, run a forward pass by hand, and explain why hidden layers with nonlinear activations make networks more expressive than linear models.
- Compute gradients with backpropagationApply the chain rule on a computation graph to find the gradient of the loss with respect to every weight, check it numerically, and recognize vanishing gradients.
- Train a neural network in practiceSet up the training loop, initialize weights sensibly, choose hyperparameters and read training curves to spot common problems.
- Compute the output of a feedforward network
- Tell overfitting from underfitting with training and held-out results, relate it to model complexity and data, and reduce it with regularization, early stopping and dropout.
- Diagnose overfitting and underfittingCompare training and held-out performance to spot overfitting and underfitting, and explain how model complexity and the amount of data affect generalization.
- Prevent overfitting with regularizationAdd L2 or L1 penalties to the loss, use early stopping and dropout, enlarge the data with augmentation, and choose the regularization strength on validation data.
- Diagnose overfitting and underfitting
Supervised Learning and Neural Networks study guide
1Set up a supervised learning problem
Learning starts with a prediction task: what describes one case, what answer is wanted, and how a mistake is measured. These choices determine the examples and the family of rules the program can learn. Turn inputs into ordered feature vectors, calculate weighted scores, and distinguish fitting a training sample from performing well on new cases. The same basic setup supports probability models, linear classifiers, and neural networks.
1.1 Describe the supervised learning task
A learning program receives examples of the behavior it should learn. In supervised learning, each example pairs an input with its correct output, called a label. The learned rule must also work on inputs that were absent during training.
Identify the task and its labels
Write a training set as . The input describes one case; the label supplies the answer for that case. An unknown target function describes the underlying relationship. With noise-free labels, . The program chooses a hypothesis to approximate that relationship.
For a spam filter, one case is an email. Its input can describe whether it contains "free," how many links it has, and whether its sender is a contact. Its label is spam or ham, meaning wanted email. A training set might contain 5,000 labeled emails; the finished filter is evaluated on 1,000 different labeled emails.
| Task | Output | Example |
|---|---|---|
| Binary classification | One of two classes | Spam or ham |
| Multiclass classification | One of several classes | A digit from 0 to 9 |
| Regression | A numerical quantity | Rainfall in millimeters |
The output defines the task. "Will more than 5 mm of rain fall?" asks for a class; "How many millimeters will fall?" asks for a number. An integer output can still be a class: digit 7 names a category, not seven times digit 1.
Supervised learning uses labeled examples. Unsupervised learning looks for structure without labels, such as customer clusters. Reinforcement learning uses rewards following an agent's actions. Creating reliable labels can require substantial human work.
Choose a family of possible rules
The hypothesis space is the family the program can search, such as linear classifiers using specified features. Learned parameters, including weights or conditional probabilities, select one member of that family. A target outside the family cannot be represented exactly, even with unlimited data.
A hyperparameter controls the learning setup: examples include a learning rate or the number of hidden units. Training fits parameters. Comparisons on validation data help choose hyperparameters. More flexible families capture more patterns but also have more ways to fit noise.
Judge predictions on new cases
Training error measures fit to examples used for learning. A rule that memorizes every training email can have zero training error and still fail on new messages. Use a validation set for model choices and keep a separate test set for the final assessment.
For a classifier, error rate is the number of wrong predictions divided by the number tested. Three errors among 40 emails give
The connection to future performance depends on the sampling setting. Independent and identically distributed, or i.i.d., examples are independent draws from the same distribution. If future spam uses very different wording, the old test set no longer represents that future stream. Report the held-out result for the population it actually represents.
Key Takeaways
- Supervised learning fits a hypothesis from input–label pairs.
- Classification predicts a class; regression predicts a numerical quantity.
- Parameters are learned; hyperparameters control the learning setup.
- Use validation data for choices and untouched test data for final assessment.
- Generalization to future cases depends on representative sampling.
1.2 Represent examples with features and measure loss
Models work with a numerical description of each case. The choice and order of these features determine what a model can notice. A loss then tells learning how costly its predictions are.
Build a feature vector
A feature can be binary, a count, or a measured number. "Contains free" becomes 0 or 1, a link count might be 4, and floor area might be 85 m². Keep the same feature order for training and prediction. A 28 by 28 grayscale image supplies pixel features.
For a category without a numerical order, use one-hot encoding. For red, green, and blue, the vectors are , , and . Codes 1, 2, and 3 would impose an artificial ordering and spacing on these colors.
Combine features into a score
A dot product multiplies corresponding weights and features, then adds:
For and , the score is
A positive weight raises the score when its feature increases; a negative weight lowers it. Weight magnitude describes sensitivity per feature unit, so comparing magnitudes across differently scaled features needs care.
The bias shifts the score independently of varying inputs. Include a constant first feature and let be its weight. Thus includes the bias feature; it is not an extra measured property. The model can then shift a decision boundary without changing the other weights.
Measure the cost of a prediction
A loss function compares a prediction with its label. Different losses express different costs:
| Loss | Calculation | Effect |
|---|---|---|
| 0/1 | 0 if correct, 1 if wrong | Counts classification mistakes |
| Squared | Gives large errors extra weight | |
| Absolute | Grows directly with error size |
For a true temperature of 10 °C and prediction of 7 °C, squared loss is 9 and absolute loss is 3. An error of 6 has squared loss 36, four times the loss for an error of 3. The average 0/1 loss is the classification error rate.
Empirical loss is average loss on the training sample. Predictions for labels give squared errors 1, 0, and 4, hence mean squared error . Add the losses before dividing by the number of examples.
Generalization loss is expected loss on new examples from the same distribution. Minimizing empirical loss can fit accidental details of the sample. Irrelevant features give a learner more opportunities to do this; near-duplicate features can also count the same evidence twice in naive Bayes. Ockham's razor favors a simpler hypothesis when alternatives fit about equally well, because extra flexibility needs support from data.
Key Takeaways
- Feature order and encoding must stay consistent across examples.
- One-hot encoding represents unordered categories without an artificial ranking.
- A dot product adds weighted feature contributions; the constant feature carries the bias.
- Squared loss emphasizes large errors more strongly than absolute loss.
- Empirical loss is a sample average; generalization loss concerns new examples.
- More features can increase opportunities to fit noise.
2Classify with naive Bayes
Naive Bayes learns class evidence by counting and combines that evidence through Bayes' rule. Work from a conditional independence assumption to class scores, then normalize them or compare their logarithms. Counts introduce a practical problem: an unseen outcome gets zero probability. Smoothing repairs that problem, and the text model shows why document counts, token counts, binary absences, and repeated words must stay distinct.
2.1 Make predictions with the naive Bayes model
Naive Bayes combines a class's starting probability with the evidence supplied by an input. Its simplifying assumption makes a large probability model learnable from relatively small samples.
Factor the evidence by class
The model assumes features are conditionally independent given the class. For a class variable and several features,
A Bayesian network shows the class as the parent of each feature. Independence is conditional: features can be strongly related overall because both depend on the class. For 100 binary features, a full joint feature table needs free probabilities per class. Naive Bayes needs only 100 probabilities per class, one for each feature's yes value.
Bayes' rule gives a class score
Choose the class with the largest score. The omitted evidence denominator is the same for all classes. A score is not yet a posterior probability: to obtain a posterior, divide it by the sum of all class scores.
Work through a binary-feature prediction
Suppose the spam prior is 0.4 and the ham prior is 0.6. The probabilities for "free" are 0.5 in spam and 0.05 in ham. For "meeting," they are 0.1 and 0.4. The new email contains "free" but lacks "meeting."
- For spam, absence of "meeting" contributes . The score is .
- For ham, that absence contributes . The score is .
- The scores sum to 0.198, so the spam posterior is .
An absent binary feature supplies evidence. If both words occur, the scores become 0.02 and 0.012, and the spam posterior falls to 0.625. "Meeting" shifts the balance toward ham even though spam still wins.
Keep the direction of conditioning straight. describes spam messages. The reverse probability, , also needs the class priors and the ham likelihood; here it is .
Use log scores without changing the winner
Long products can underflow to zero in computer arithmetic. Two hundred factors of 0.01 give , smaller than the least positive double-precision number. Compare
instead. Logarithms preserve order and turn multiplication into addition. Here beats ; among negative scores, the less negative score is larger.
Naive Bayes is generative: it models the prior and how features arise within each class. Logistic regression is discriminative: it models the class probability from the input directly. Binary-feature naive Bayes also has a linear log-odds boundary. Correlated features, such as "Hong" and "Kong," can make its posterior too extreme by counting overlapping evidence. A class prediction can be right even when the assigned probability is too extreme.
Key Takeaways
- Naive Bayes assumes conditional feature independence given the class.
- Multiply the prior by every observed feature-value likelihood, including binary absences.
- Normalize class scores to obtain posterior probabilities.
- Log scores prevent underflow and preserve the winning class.
- Correlated evidence can produce overconfident probabilities.
2.2 Estimate naive Bayes probabilities from data
Naive Bayes learns by counting. The important choices are which population belongs in a denominator and how much protection to give an outcome that has not appeared yet.
Estimate probabilities within the right group
The maximum likelihood estimate, or MLE, makes the observed data most probable. For a class prior, divide the class count by the total number of examples. For a conditional feature probability, restrict both counts to the class:
Consider 100 emails: 40 spam and 60 ham. "Free" appears in 20 spam messages and 3 ham messages; "meeting" appears in 4 spam and 24 ham messages. Thus the spam prior is 0.4. The "free" estimates are for spam and for ham. The "meeting" estimates are and . Dividing a feature-and-class count by 100 would estimate a joint probability, not the requested conditional probability.
Repair zero counts
Suppose "prize" appears in 8 spam messages and no ham message. Its ham MLE is zero. Any new message containing it gets ham score zero, whatever its other features say. A finite sample's missing outcome has become a claim of impossibility.
Add-k smoothing gives every possible feature value a pseudo-count of :
Here is the number of values of this feature. For a yes/no feature it is 2, not the number of words being modeled. With add-one smoothing,
Both outcomes receive a pseudo-count. In ham, the absent value therefore has probability . The two probabilities sum to 1. Adding only to the numerator would break this normalization.
Choose the strength of smoothing
The strength is a hyperparameter. At zero it gives MLE. As it becomes large, each probability approaches the uniform value and class-specific evidence weakens. Smoothing trades some fit to the observed counts for more stable predictions on new cases.
Compare settings such as 0.1, 0.5, 1, 2, and 5 on validation data. Keep the test set separate for the final assessment. A large setting can underfit; a very small setting may leave rare features with unstable estimates.
The same pseudo-count matters less when real counts grow. Among 6,000 ham emails with 300 containing "free," the MLE is 0.05 and the add-one value is . With many observations, the data dominate the pseudo-counts. Class priors are commonly left unsmoothed when every class is well represented. A single pass over labeled examples can collect the counts, which makes this training method fast.
Key Takeaways
- MLE estimates probabilities with relative frequencies in the relevant class.
- A zero feature count can erase an entire class score.
- Add-k smoothing adds k to every outcome count and k times the number of outcomes to the total.
- Choose smoothing strength on validation data; its influence decreases as counts grow.
2.3 Classify text with a bag-of-words model
A bag of words turns text into word counts. It gives a simple classifier evidence about vocabulary while discarding the order in which words occur.
Count tokens, not just documents
"The cat saw the dog" and "the dog saw the cat" have the same bag: "the" twice and each other word once. A token is an occurrence; the vocabulary is the set of distinct words represented by the model.
In multinomial naive Bayes, every word position is an independent draw from a class-specific word distribution. A word appearing three times contributes three factors:
The matching log score is . The prior appears once per document. The word count multiplies its log probability.
Estimate word probabilities from token counts within a class. With smoothing,
where counts all training tokens in that class and counts vocabulary words. Suppose spam contains 200 tokens, including "cash" 9 times, and the vocabulary contains 1,000 words. MLE gives . Add-one gives , while gives . A large vocabulary makes even one pseudo-count per word substantial.
Classify a short document
Sports and politics each have prior 0.5. Word probabilities are:
| Word | Sports | Politics |
|---|---|---|
| goal | 0.05 | 0.005 |
| vote | 0.004 | 0.04 |
| match | 0.03 | 0.006 |
For "goal goal vote match," the sports score is
The politics score is . Sports wins by a factor of 50, and its normalized posterior is . Omitting the second "goal" would discard part of the evidence. In practice use the log scores, about −15.71 and −19.62, to avoid tiny products.
Keep the text models distinct
A Bernoulli text model uses one yes/no feature per word and includes every absent word's factor. The multinomial model uses occurrence counts and has no separate absent-word factors. Its denominators count tokens, not documents. Mixing those choices produces neither model correctly.
A vocabulary word unseen in one class needs smoothing. A word outside the vocabulary has no modeled probability and is usually skipped. Alternatively, training can reserve an unknown-word token with its own class-specific probability.
The bag ignores context: "good" supplies the same evidence inside "not good" and "very good." Adding bigrams, or word pairs, can represent a phrase such as "not good." Near-duplicate or neighboring words can still produce overconfident probabilities. The model remains useful as a fast baseline for topics, spam, sentiment, or language identification.
Key Takeaways
- A bag of words records occurrence counts and ignores order.
- Multinomial naive Bayes uses token probabilities, with one factor per occurrence.
- Token smoothing uses the total class token count plus k times vocabulary size.
- Bernoulli text models also model absences; multinomial models use counts.
- Unknown vocabulary items are skipped unless an unknown-word token was trained.
- Bigrams capture some local context that single-word counts lose.
3Train linear classifiers
A weighted sum gives a simple geometric classifier: its zero-score boundary divides the input space. The perceptron moves that boundary after mistakes, while logistic regression assigns probabilities and learns through a smooth loss. Follow both kinds of predictions and updates, see why XOR needs changed features, and extend class scoring to several classes. The geometry also explains what multiplying or omitting weights changes.
3.1 Read linear decision boundaries
A linear classifier makes a decision from a weighted sum. Geometry shows which patterns that sum can separate and why some tasks require new features.
Read the score and boundary
Include the constant bias feature first: . Compute and predict for or for . A zero score belongs to the positive class under this convention.
With at least one nonzero feature weight, the decision boundary is . For two varying features it is a line; for three it is a plane; in general it is a hyperplane. The non-bias weight vector is perpendicular to this boundary and points toward the positive side.
For , the score is and the boundary is . Point scores 1, scores −1, and scores zero. The predictions are positive, negative, and positive.
The geometric distance is the score magnitude divided by the length of the non-bias weight vector:
For it is . Multiplying every weight by a positive constant changes the score but leaves both the distance and the predicted class unchanged. Leaving out the bias restricts boundaries to pass through the origin.
Decide whether a line is enough
Data are linearly separable when one weight vector classifies every point correctly. For AND, use . Only has positive score; the other three binary inputs have negative scores.
XOR labels and positive, but and negative. No line can separate those diagonally opposite pairs. To see why, the negative origin requires . The two positive points require , while the negative point requires . Together they require , a contradiction.
The feature representation can change separability. Add the feature and use weights . The four XOR inputs then score −0.5, 0.5, 0.5, and −0.5 in the order . The rule is linear in the expanded feature vector, even though it is nonlinear in the original inputs. A hidden layer can learn useful transformed features.
Extend scoring to several classes
Keep one vector per class and choose the largest dot product. For , vectors , , and give scores 3, 2, and 2. Class A wins. These are comparative scores, not probabilities; they need not lie between zero and one or sum to one.
Key Takeaways
- The sign of a dot product selects the binary class; a zero score is positive here.
- The bias moves the boundary away from the origin.
- Positive weight scaling preserves the boundary and predictions.
- XOR needs transformed features or a nonlinear model.
- Multiclass linear prediction selects the largest class score.
3.2 Learn weights with the perceptron rule
The perceptron learns a linear decision rule by correcting mistakes as they occur. It changes weights directly, without fitting probabilities or differentiating a smooth loss.
Update one example at a time
Use labels , include the bias feature, and start with zero weights. A score of zero predicts . For each example, predict using the current weights. Leave them unchanged if correct; otherwise apply
A positive example adds its feature vector. A negative example subtracts it. The score on that example changes by , so it moves toward the correct sign. The bias feature makes the squared length positive. One update can still leave the example wrong and can disturb earlier predictions.
An epoch is a full pass through the training set. Stop after an entire mistake-free epoch or a chosen pass limit.
Trace two passes
Take the examples in this order, with the bias coordinate already included:
| Example | Input | Label |
|---|---|---|
| A | −1 | |
| B | +1 | |
| C | −1 | |
| D | +1 |
- A scores zero and is wrongly positive. Subtract A to get .
- B now scores . Add B to get .
- C scores −2 and D scores 4. Both are correct, so no update occurs.
- On the next pass, A, B, C, and D score −4, 4, −2, and 4. No mistakes remain, so stop.
The learned boundary is . Predictions must use the weights after all preceding updates, not the weights at the start of the epoch.
Understand convergence and its limits
The perceptron convergence theorem guarantees finitely many mistakes for linearly separable training data. If augmented inputs have lengths at most and a unit-length separator achieves positive signed margin , the mistake bound is . The guarantee finds a separator; it does not select the widest margin or the best test performance.
Nonseparable data, including XOR in its original features or conflicting labels, never allow a mistake-free pass. Set a training limit and use validation performance to choose weights. An averaged perceptron predicts using the average of weights over training steps. A fixed positive learning rate simply scales every weight when starting from zero, so it leaves the binary prediction sequence unchanged; a changing rate can alter that behavior.
Correct a multiclass prediction
On a multiclass mistake, add the input to the true class vector and subtract it from the predicted class vector. Leave the rest unchanged. For input , true class B and predicted A, vectors and become and . Their new scores are −2 and 7. The unchanged C score is 2, so B now wins. Like the binary perceptron, this model outputs a class, not a probability.
Key Takeaways
- Update only after a wrong prediction, using the label times the augmented input.
- Use the latest weights for each new example.
- One epoch visits every training example.
- Separable data have a finite-mistake guarantee; nonseparable data do not.
- A multiclass update raises the true class score and lowers the mistaken winner.
- A perceptron prediction is a class, not a probability.
3.3 Predict probabilities with logistic regression
Logistic regression turns a linear score into a probability for a binary class. Its smooth output gives a graded training signal even when a hard classification is already correct.
Convert a score into probability
For labels 0 and 1, compute and
The sigmoid increases from values near zero to values near one. It gives , , , and . Predicting class 1 when is equivalent to using , so this decision boundary remains linear.
The score equals the log-odds:
With weights and input , five hours give score zero and probability 0.5. At 7.5 hours the score is 2 and the probability is about 0.881. Each extra hour adds 0.8 to log-odds and multiplies odds by . It does not add 0.8 to probability. A predicted probability of 0.7 concerns this example's class; it is not a report of 70% model accuracy.
Train with log loss
For one example, binary log loss is
Only the term for the observed label remains. If , use ; if , use . At , these losses are about 0.105 and 2.303. A confident wrong prediction is much more costly than an uncertain one; gives loss about 0.693 for either label.
Maximum likelihood chooses weights that assign high joint probability to the observed labels. Taking a negative logarithm turns their probability product into the sum of log losses. Gradient descent fits the weights because there is no general closed-form solution.
The logistic log loss is convex in the weights, so every local minimum is global. The 0/1 loss is flat almost everywhere and supplies no useful gradient; squared loss after the sigmoid loses this convexity. On separable training data, unregularized log loss can decrease as weights grow without bound, so a finite maximum-likelihood solution is absent. A weight penalty controls that growth.
Use softmax for more classes
Give each class a score and normalize exponentials:
Scores produce probabilities about . Adding one constant to every score changes neither the probabilities nor the winning class because the common exponential factor cancels. With two classes, softmax is a sigmoid of the score difference.
Logistic regression models directly and fits weights jointly. It does not assume feature independence. Naive Bayes estimates a prior and feature distributions by counting; it can be especially effective with small data, but correlated evidence can make its probabilities too extreme.
Key Takeaways
- The sigmoid maps a linear score to a probability for class 1.
- Weights change log-odds linearly, not probability linearly.
- Log loss penalizes confident wrong predictions strongly.
- Logistic log loss is convex, but separable data need regularization for finite fitted weights.
- Softmax normalizes class scores into probabilities.
- Logistic regression fits class probabilities directly without naive Bayes feature independence.
4Optimize models with gradient descent
Gradient descent connects a prediction rule to a method for fitting its parameters. Derivatives tell how a loss changes locally; a learning rate turns that information into an update. Work through one- and two-parameter steps, then compare full-data updates with noisy single-example and mini-batch updates. Logistic regression provides a concrete derivation in which the chain rule simplifies to prediction error times input.
4.1 Minimize a loss by following the gradient
Training often means finding weights that make a loss small. Gradient descent uses the local slope of that loss to choose the next weights, repeating until a stopping rule is met.
Find the downhill direction
A partial derivative measures how the loss changes when one parameter varies and the others stay fixed. The gradient collects all these derivatives. For
At the gradient is . It points in the direction of steepest local increase under Euclidean distance; its negative points downhill. A smooth minimum has zero gradient, but a zero gradient can also occur at a saddle point or maximum.
With positive learning rate , update
Compute the entire gradient before changing any weight. From with , the next point is , then . Loss falls from 7 to 3.04 to about 1.72. The second coordinate changes faster because its curvature is larger.
See how step size controls convergence
For , the derivative is . From zero with rate 0.1:
- The first gradient is −6, so the next weight is 0.6.
- At 0.6 the gradient is −4.8, so the next weight is 1.08.
- The following values are 1.464, 1.7712, and about 2.017.
Each step multiplies the distance to 3 by . For this loss, convergence from a nonoptimal start needs . Rate 1 bounces between 0 and 6; rate 1.1 produces 6.6, −1.32, and 8.184, moving farther away. A smaller rate can be stable but slow. The same rate is not suitable for every loss or feature scale.
Differentiate a prediction loss
For a linear predictor and one example with squared loss ,
Use , , and weights . The prediction is 2, so the gradient is . A rate of 0.05 gives new weights . The next prediction is 3.5 and loss falls from 9 to 2.25. The bias derivative has input factor 1, while the slope derivative includes the measured input.
Read the loss surface
A convex loss has no inferior local minima: every local minimum is global. Linear squared loss and logistic log loss are convex. Neural network losses are generally nonconvex, with saddle points and flat regions as well as minima. Initialization can affect the final result.
Feature scales also affect optimization. Area up to 200 m² and room counts up to 6 can stretch the loss surface into a narrow valley. Standardization subtracts each feature's training mean and divides by its training standard deviation. Better-scaled coordinates reduce zigzagging. Stop using a chosen step budget, small gradients, or lack of improvement.
Key Takeaways
- A gradient collects partial derivatives and points toward steepest local increase.
- Subtract a learning-rate-scaled gradient to move downhill.
- Compute every gradient at the same weights before updating.
- Too large a learning rate can cause oscillation or divergence.
- Convex losses have no inferior local minima; network losses are generally nonconvex.
- Feature scaling can make optimization more stable and efficient.
4.2 Train with stochastic and mini-batch gradient descent
Computing a gradient over every example can be costly. Stochastic and mini-batch updates trade a perfectly averaged direction for more frequent, cheaper steps.
Choose how much data informs an update
| Method | Gradient for one update | Main trade-off |
|---|---|---|
| Batch | Average over all training examples | Exact training gradient, expensive steps |
| Stochastic | One randomly selected example | Cheap, noisy steps |
| Mini-batch | Average over a small batch | Balances noise and efficient parallel work |
An epoch visits the whole training set once. With 10,000 examples and batches of 100, an epoch has 100 update steps. Shuffle examples between epochs so the same groups do not recur in the same order.
A uniformly chosen single-example gradient has expectation equal to the full training gradient. Individual steps can nevertheless increase total loss. Plotting loss over epochs gives a clearer trend than judging one update. Noise can help movement around saddle points and shallow minima, but a fixed large learning rate also keeps weights jittering near a solution. A decreasing learning-rate schedule helps settle them.
Derive the logistic update
Let , , and use binary log loss. Its derivative with respect to probability is
Multiplying by the sigmoid derivative leaves . Since , the complete gradient is
Subtracting it gives the equivalent update . For a batch, average these vectors using the same current weights before making one update. Summing instead of averaging multiplies the effective learning rate by batch size.
Work one stochastic step
Start at with input , target 1, and rate 0.5. The score is zero, so . Then
The new score is and the new probability is about 0.818. This example's log loss falls from about 0.693 to 0.201. That improvement concerns this example; a stochastic step need not improve every training case.
The perceptron also uses a label-related correction times the input, but it uses ±1 targets and changes weights only on mistakes. Logistic regression uses 0/1 targets and a smooth probability error. At finite weights, it can keep updating after the predicted class is correct.
Recognize common optimizer variants
Momentum carries a running average of gradient directions, helping movement along consistent directions and reducing oscillation. Adam combines this with adaptive per-parameter step sizes. Both still need a suitable learning rate. Compare settings with validation results and record validation loss along with training loss to decide when further training stops helping.
Key Takeaways
- Batch, stochastic, and mini-batch methods differ in examples used per update.
- An epoch is a full data pass, not a single update.
- For binary logistic log loss, the gradient is prediction minus target times input.
- Average mini-batch gradients before updating.
- Stochastic loss can fluctuate; schedules reduce step size over time.
- Momentum and Adam modify how gradient information produces steps.
5Build and train neural networks
Hidden layers build features that a single linear score cannot express. Follow values through a small network, count its weights and biases, and match its final activation to the target. Backpropagation sends derivative information in the opposite direction so all parameters can be trained efficiently. Initialization, input scales, mini-batches, and validation curves then connect those calculations to a working training loop.
5.1 Compute the output of a feedforward network
A neural network connects many simple units. Hidden layers transform inputs into learned features; nonlinear activations let those features represent patterns that a single linear classifier misses.
Compute units and count parameters
A unit calculates , then outputs . Here the incoming activations are its inputs, and the bias is shown separately. This is equivalent to including a constant bias feature.
| Activation | Output rule or range | Common role |
|---|---|---|
| Sigmoid | , between 0 and 1 | Binary probability output |
| tanh | Between −1 and 1 | Centered nonlinear hidden output |
| ReLU | Cheap nonlinear hidden unit |
A feedforward network has no directed cycles: information moves from input through hidden layers to output. In a fully connected layer, each unit receives every output of the previous layer. A layer with inputs and units has weights and biases. Three inputs, four hidden units, and two output units therefore give
trainable parameters. Count one bias per receiving unit, not one per connection. Networks with many hidden layers are called deep.
Follow a network that computes XOR
Use two hidden ReLU units and a linear output:
For , the hidden values are , so the output is 0. For either or , they are , giving 1. For , they are , giving . The hidden representation allows the output to distinguish the XOR classes.
Without nonlinear activations, stacking layers would still make one affine transformation. Ignoring biases for clarity, . Depth alone would add no nonlinear expressive power. The bends introduced by activations change what the network can represent.
Match outputs to targets
For a numerical regression target, a linear output and squared loss are a standard choice. For binary labels, use one sigmoid output and binary log loss. For one of several classes, use softmax outputs and cross-entropy . Probabilities with the second class correct give loss about 1.41. The loss uses the probability assigned to the true class, even when another class wins.
The universal approximation theorem says a sufficiently wide hidden layer with a suitable nonlinear activation can approximate any continuous function on a closed, bounded input region to arbitrary accuracy. It is an existence result, not a guarantee that training finds the weights or that a small network suffices. Depth can represent some functions much more efficiently.
Hidden representations can progress from image edges and textures to object parts. Architectures also build in useful structure: convolutional networks share small weight sets across image positions, while recurrent networks share weights across sequence steps.
Key Takeaways
- A unit applies an activation to a weighted sum plus bias.
- A fully connected layer has one weight per connection and one bias per receiving unit.
- Hidden nonlinear features let networks represent patterns such as XOR.
- Output activations and losses must match the target type.
- Universal approximation describes representational possibility, not training success.
- Weight sharing captures repeated spatial or sequential structure.
5.2 Compute gradients with backpropagation
Backpropagation computes how every parameter affects loss. A forward pass stores the values needed by the chain rule; a backward pass reuses them to avoid repeating the same derivative calculations.
Move through a computation graph
A computation graph separates sums, products, and activations into operations. Along a path through an intermediate value,
When a parameter affects loss along several paths, add their contributions. For unit , write . Its backward signal is
The sum includes units that receive its output. A weight from activation into unit has gradient . The bias gradient is simply because its input is 1.
Work a forward and backward pass
Let , , , and . Start with , , and target .
- Forward: the hidden sum is 1, hidden output is 1, prediction is 3, and loss is 4.
- At the output, . Thus .
- Going back through the output weight gives . The hidden sum is positive, so the ReLU derivative is 1.
- The first weight's gradient is therefore .
With rate 0.01, update both weights from these stored gradients:
A fresh forward pass gives hidden output 0.52, prediction 1.5392, and loss about 0.291. Using 2.96 during the preceding backward pass would mix two parameter states and produce the wrong gradient.
Check derivatives and recognize weak signals
A numerical check approximates one derivative by
With , the first weight's derivative above is 24. This needs two forward passes per weight, so it is useful for checking, not large-scale training. Backpropagation computes all gradients at a cost of the same order as a forward pass. Libraries implement this as reverse-mode automatic differentiation.
Sigmoid has derivative ; tanh has derivative . ReLU's derivative is 1 above zero and 0 below; zero is commonly assigned derivative 0. A ReLU unit whose preactivation is negative for every input is dead and receives no useful gradient through its activation. Softmax cross-entropy has score gradient for one-hot targets.
Repeated small derivative factors cause vanishing gradients. A chain of 10 sigmoid units with connecting weights 1 has derivative at most . Wider graphs also depend on weights and summed paths. ReLU, suitable initialization, and residual connections reduce this problem. Large backward signals can instead explode; gradient clipping caps their size.
Key Takeaways
- Backpropagation multiplies derivatives along paths and adds contributions from different paths.
- A weight gradient is its incoming activation times the receiving unit’s delta.
- Store forward values and compute all gradients before updating.
- Numerical differences check gradients but cost too much for routine training.
- Repeated small factors can vanish; large factors can explode.
- Dead ReLU units have zero activation gradients on all their inputs.
5.3 Train a neural network in practice
Network training needs more than a correct derivative. Starting weights, input scales, update settings, and held-out results all affect whether useful features are learned.
Break symmetry and scale signals
Initialize weights randomly so hidden units begin differently. If a layer's units have identical weights and the same outgoing connections, they compute the same values, receive the same updates, and remain copies. All-zero network weights create this symmetry. Biases can start at zero because random connection weights already distinguish units.
The random scale matters. Glorot, or Xavier, initialization is suited to tanh and sigmoid units; He initialization accounts for ReLU activations. These schemes aim to keep signal sizes from shrinking or growing too much from layer to layer.
Normalize inputs as well. Dividing pixel values by 255 puts them between zero and one. Standardization subtracts a feature's training mean and divides by its training standard deviation. Apply the same fitted transformation to later inputs. Moderate initial sums help sigmoid and tanh avoid saturated regions with very small derivatives; comparable feature scales also improve optimization.
Run the training loop
- Initialize the weights and choose the optimizer and settings.
- At each epoch's start, shuffle the training examples.
- For each mini-batch, run a forward pass and compute average loss.
- Backpropagate, then update all parameters using that batch's gradients.
- At the epoch's end, record training and validation results.
For 784 pixel inputs, 128 hidden ReLU units, and 10 softmax outputs, the parameter count is
With 60,000 images and batch size 64, there are 937 full batches and one final batch of 32 images: 938 updates per epoch. The final short batch still uses its own average gradient.
Read training curves
| Observed pattern | What to investigate |
|---|---|
| Loss jumps or becomes NaN | Learning rate too large or unstable calculations |
| Loss falls very slowly | Rate too small or gradients too weak |
| Training improves while validation worsens | Overfitting and stopping time |
These patterns guide diagnosis; several causes can share a symptom. For a slowly learning sigmoid network, inspect input scale and activation saturation along with the learning rate. A high training accuracy only shows fit to training examples. A large network can even memorize random labels.
The main hyperparameters include learning rate, batch size, epoch count, width, depth, activation, and optimizer. Compare them on validation data. Keep the test set for evaluating the selected configuration. Increasing width changes parameter count and capacity; increasing epochs gives the same parameters more update steps.
Network loss is nonconvex. Different random starts can reach different weights and accuracies. In large networks, saddle points and flat regions often slow progress more than poor local minima. Momentum and Adam help optimize such surfaces, but held-out performance still decides whether the fitted pattern is useful.
Key Takeaways
- Random weights distinguish hidden units; all-zero network initialization creates symmetry.
- Initialization scale and input normalization support stable signals.
- The loop alternates forward pass, loss, backpropagation, and optimizer update.
- Count mini-batch steps by rounding the examples-per-batch quotient upward.
- Use training and validation curves together to investigate learning problems.
6Recognize and control overfitting
A useful learned rule must survive beyond its training sample. Compare training and validation results to diagnose excessive flexibility or an overly restricted model, and separate those problems from changed data conditions. Weight penalties, early stopping, dropout, and valid data augmentation offer different ways to control overfitting. Their settings still need validation: stronger restrictions can remove real signal along with noise.
6.1 Diagnose overfitting and underfitting
A model can fit its training sample well without learning a dependable pattern. Compare training and held-out results to understand whether the model is too restricted, too flexible, or facing different data.
Compare two kinds of error
Generalization is performance on new examples from the same distribution. Underfitting occurs when the model is too restricted to capture the pattern. Overfitting occurs when it fits sample-specific noise so closely that new predictions suffer.
| Model | Training accuracy | Validation accuracy | Interpretation |
|---|---|---|---|
| A | 99% | 71% | Large gap suggests overfitting |
| B | 74% | 73% | Underfitting if stronger models can do better |
| C | 92% | 90% | Best held-out performance here |
Choose C from these validation results. A's higher training score is not an advantage on the held-out cases. B's small gap is not enough to make it good: both scores are low relative to what the task allows. Difficulty, noise, and achievable performance matter when interpreting a small gap.
Relate capacity to noise
Capacity describes how flexible the hypothesis family is. Ten noisy points may lie near a straight trend. A line uses two coefficients and misses the points slightly. A degree-9 polynomial uses ten coefficients and can interpolate all ten distinct input points, reaching zero training error. Between and beyond them, that polynomial can swing sharply and predict badly.
As capacity increases, training error generally falls. Held-out error often falls at first as genuine structure becomes representable, then rises as noise is fitted. Compare candidate capacities using held-out results. This familiar pattern is a guide to model choice, not a guarantee that every possible network-size curve has exactly that shape.
High bias means systematic error from a restrictive family. High variance means the learned rule changes substantially across training samples of the same size. Underfitting commonly involves high bias; overfitting commonly involves high variance.
Separate more data from different data
For fixed capacity, more representative examples usually reduce overfitting. A degree-9 polynomial cannot generally interpolate 1,000 noisy points exactly, so its fit must compromise. Large networks can still memorize large samples, including random labels. More data reduce risk without eliminating the need for held-out checks. Wrong or noisy labels add accidental patterns the learner might fit.
Distribution shift is a different problem. A classifier trained and tested on daytime photos can fail on night photos even when its daytime generalization is good. Those new inputs come from a different distribution. More regularization alone does not supply missing night conditions.
Preserve the meaning of the final test
Train candidates on the training set and compare their settings or capacities on validation data. Once a candidate is chosen, measure it on the untouched test set. Using test scores to change architecture or choose an epoch turns that set into another source of model selection, making its reported performance optimistic. Overfitting can affect polynomials, naive Bayes, perceptrons, and networks; it is a relationship between learning and data, not a property unique to one algorithm.
Key Takeaways
- Overfitting combines strong training fit with weaker performance on new data.
- Underfitting can produce similarly poor training and held-out results.
- Capacity permits useful structure and accidental patterns to be fitted.
- More representative data usually help at fixed capacity, but memorization remains possible.
- Distribution shift differs from overfitting.
- Use validation for choices and preserve the final test set.
6.2 Prevent overfitting with regularization
Regularization changes learning to improve predictions on new data. It can constrain weights, limit training duration, interrupt reliance on particular units, or supply more valid examples.
Penalize large weights
A regularized objective combines data loss and a complexity penalty:
For L2, use , usually excluding the bias. Weights and give penalty . The added derivative is . Under ordinary gradient descent,
With rate 0.1 and strength 0.1, the shrinkage factor is 0.98; a weight of 5 contributes 4.9 before the data-loss step. This is the weight-decay interpretation for this optimizer. With adaptive optimizers such as Adam, an L2 penalty and separately applied weight decay are different operations.
L1 uses . It favors sparse solutions with many weights exactly zero, selecting features. L2 usually shrinks weights without making them exactly zero. Neither penalty is a rule to set every weight to zero.
The strength is a hyperparameter. Zero removes the penalty; excessive strength makes the model underfit. Compare values across orders of magnitude on validation data. A positive L2 penalty also controls the divergent weights of separable logistic regression.
Keep the best stopping point
Early stopping monitors validation loss, saves the best weights, and stops after a patience interval without improvement. For losses 0.62, 0.48, 0.41, 0.39, 0.40, 0.43, and 0.47 at epochs 1–7, the best epoch is 4. Patience 3 allows epochs 5–7, then stops and restores epoch 4's weights. The final trained epoch is not necessarily the saved model.
Train with dropout
At each training step, dropout independently sets hidden-unit outputs to zero with probability . Units must learn without relying on a particular partner always being present. At prediction time dropout is disabled and all units participate.
In inverted dropout, divide surviving activations by during training. If , surviving outputs double, so their expected value matches the undropped activation. This scaling is not applied again at prediction time.
Add valid variation
Collecting more representative data and using a simpler model can reduce overfitting. Data augmentation adds transformed training examples whose labels stay correct, such as suitable shifts, crops, or brightness changes. A transformation must suit the task: rotating a handwritten 6 by 180° can change it into a 9, so keeping label 6 would teach the wrong relationship.
Laplace smoothing is another regularizer: pseudo-counts make naive Bayes less dependent on sparse counts. Use validation data to choose smoothing, penalties, dropout rates, or stopping times. Watch both training and validation error so protection against overfitting does not become excessive restriction.
Key Takeaways
- L2 penalizes squared weights; L1 favors sparse weights.
- Regularization strength trades data fit against restrictions and is selected on validation data.
- Early stopping restores the best validation checkpoint.
- Inverted dropout rescales surviving training activations and is disabled for prediction.
- Augmentation must preserve the correct label.
- Smoothing, simpler models, and more representative data also help control overfitting.
- L2 shrinkage under gradient descent must be distinguished from adaptive weight-decay implementations.
Supervised Learning and Neural Networks examples
1Set up and check a supervised task
10 steps
- 1IntroductionTurn examples into a learning task
A supervised learner needs paired inputs and answers. Before choosing an algorithm, identify what one case means and what output is wanted.
Follow an email filter from its labels to a numerical representation and a loss. The final check is whether its learned rule works on fresh cases, so fitting and assessment need separate data roles.
- 2ExampleIdentify the case and label
For a spam filter, one case is an email. Inputs can record "contains free," number of links, and whether the sender is a contact. The label is spam or ham, meaning wanted email.
The learner fits a hypothesis from 5,000 labeled examples. That hypothesis takes a new email's features and predicts its label. Its learned weights are parameters; settings such as model size are hyperparameters.
- 3ExplanationKeep fitting and assessment separate
Use training data to fit parameters and validation data to compare settings. Keep test cases untouched until the model has been selected.
This matters even if a memorizing rule gets every training email right. Its stored answers may say little about unfamiliar messages. Held-out performance represents future performance when the examples are independent draws from the same distribution; changed spam wording can break that connection.
- 4ChallengeClassify the prediction task
A weather service wants one model to predict rainfall in millimeters and another to predict whether more than 5 mm will fall. How do their task types differ?
---reveal---
The measured amount is a regression target. The yes/no event is a binary classification target. Both can use labeled historical weather cases; the fact that each concerns future weather does not make either unsupervised learning.
- 5ExplanationChoose a numerical representation
A feature vector lists properties in a fixed order. Binary indicators represent yes/no facts, counts represent occurrences, and real numbers represent measurements.
For unordered colors, use one-hot indicators: red is and blue is . Codes 1, 2, and 3 would impose an artificial numeric relationship. Add a separate first coordinate fixed at 1 when the model uses a bias inside its dot product.
- 6ExampleAdd weighted contributions
Take augmented input and weights . Multiply matching coordinates, then add:
The constant first input makes 2 the bias contribution. Increasing the second coordinate lowers the score because its weight is negative. This calculation produces a score; a classifier still needs a rule connecting scores to class predictions.
- 7ExampleMeasure prediction cost
For numerical predictions against targets , the squared errors are 1, 0, and 4.
Squaring before averaging prevents signed errors from canceling. Squared loss emphasizes large misses: doubling an error quadruples its loss. For classification, averaging 0/1 losses instead gives the fraction of wrong predictions.
- 8ChallengeCalculate a score and its loss
A numerical predictor has augmented input and weights . Its target is 7. What prediction and squared loss result?
---reveal---
The dot product is . The squared loss is . The target is used to measure the prediction's error; it is not another input coordinate. An absolute-loss calculation would give 2, a different cost for the same miss.
- 9ChallengeChoose what the result supports
A team adds many word features and reduces training error to zero, but validation error rises. Should it choose this model because every training label is now correct?
---reveal---
No. Extra features gave it more ways to fit the training sample, but the held-out comparison became worse. Use validation results to compare the candidates, then assess the selected model on untouched test cases. The objective is useful predictions on new inputs.
- 10RecapKeep the learning roles clear
Start with input–label pairs and a family of possible prediction rules. Represent each input consistently, compute the prediction, and use the chosen loss to measure its cost.
Training fits parameters. Validation guides model choices. Testing assesses the selected result. Accuracy and loss describe performance on particular cases; applying those results to future inputs also depends on how the cases were sampled.
2Predict with naive Bayes and word counts
15 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionCombine class evidence by counting
- 2ExplanationBuild a score for each class
- 3ExampleInclude a missing binary feature
- 4ExampleNormalize and compare logs
- 5ChallengeUse both observed values
- 6ExampleEstimate within each class
- 7ExplanationProtect an unseen outcome
- 8ChallengeSmooth a binary feature
- 9TipSet smoothing with held-out evidence
- 10ExplanationChange from indicators to token counts
- 11ExampleSmooth over a vocabulary
- 12ExampleKeep every repeated word
- 13ChallengeUse repeated-token evidence
- 14ChallengeRepair a model mismatch
- 15RecapMatch evidence to the probability model
3Move boundaries and fit class probabilities
17 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionLearn from a weighted score
- 2ExampleRead the boundary
- 3Key InsightSeparate score from distance
- 4ExampleChange features for XOR
- 5ChallengePredict after changing the bias
- 6ExplanationUpdate only on mistakes
- 7ExampleTrace the first two mistakes
- 8ExampleCheck the next full pass
- 9ChallengeCarry the current weights forward
- 10ConnectionRaise one class and lower another
- 11ExplanationTurn a score into probability
- 12ExampleScore the observed label
- 13Key InsightConvexity does not bound weights
- 14ChallengeFind a log loss
- 15ConnectionNormalize several class scores
- 16ChallengeCompare two learning signals
- 17RecapConnect representation and learning
4Follow gradients and average updates
13 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionUse derivatives to improve weights
- 2ExplanationRead the gradient
- 3ExampleMake a simultaneous step
- 4ExampleCheck what the rate changes
- 5ChallengeDifferentiate before stepping
- 6TipMatch scales to optimization
- 7ExplanationChoose a gradient sample
- 8ExplanationSimplify the logistic derivative
- 9ExampleRun a logistic stochastic update
- 10ChallengeAverage before updating
- 11ConnectionManage noisy directions
- 12ChallengeDiagnose a change in batch size
- 13RecapSeparate direction, size, and sampling
5Compute and train a small network
20 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionFollow values forward and derivatives backward
- 2ExplanationCompute one unit
- 3ExampleCount a small network
- 4ExampleBuild nonlinear features for XOR
- 5ChallengeKeep output activation separate
- 6ConnectionMatch output to the task
- 7ExplanationStore the forward state
- 8ExampleFind the output-weight gradient
- 9ExampleCarry the signal to the hidden weight
- 10ExampleUpdate both weights together
- 11ChallengeDifferentiate through an active unit
- 12TipCheck a derivative numerically
- 13Key InsightNotice weakened backward signals
- 14ExplanationStart units differently
- 15ExampleCount parameters and batch steps
- 16ExplanationRun one batch, then monitor the epoch
- 17ChallengeChoose a response to the curves
- 18ChallengeSeparate poor learning from low capacity
- 19ConnectionRepresentations depend on training
- 20RecapCoordinate the entire training step
6Diagnose and control overfitting
13 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionFind the fit that survives new data
- 2ExampleCompare held-out performance
- 3ExplanationConnect capacity with sample noise
- 4ChallengeDiagnose a richer model
- 5ConnectionSeparate changed conditions from noise fitting
- 6ExplanationAdd a weight penalty
- 7ExampleDerive L2 shrinkage
- 8ChallengeChoose a sparse fit
- 9ExampleRestore the best checkpoint
- 10ExplanationKeep dropout expectations stable
- 11ChallengeCheck an augmentation label
- 12ChallengeChoose the final evaluation order
- 13RecapUse the right control for the observed problem
Supervised Learning and Neural Networks practice questions
Set 1: Counts, updates, and training behavior10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
Show answerHide answer
Question 3 of 10
Show answerHide answer
Question 4 of 10
Show answerHide answer
Question 5 of 10
Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
Show answerHide answer
Question 10 of 10
Show answerHide answer
Set 2: From labeled examples to learned predictions10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 3: Combine model calculations and learning rules10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 4: Diagnose models and preserve valid comparisons10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 5: Transfer the methods to new learning problems10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
A
Activation function
Adam
Averaged perceptron
B
Backpropagation
Bag of words
Batch gradient descent
Bernoulli naive Bayes
Bias
Bigram
C
Chain rule
Class prior
Classification
Computation graph
Conditional independence
Convex loss
D
Data augmentation
Dead ReLU
Decision boundary
Distribution shift
Dot product
Dropout
E
Early stopping
Empirical loss
Epoch
F
Feature vector
Feedforward network
Fully connected layer
G
Generalization
Generative model
Gradient
Gradient clipping
Gradient descent
H
He initialization
Hidden layer
Hyperparameter
Hyperplane
Hypothesis space
I
Initialization
L
L1 regularization
L2 regularization
Label
Laplace smoothing
Learning rate
Learning-rate schedule
Linear classifier
Linear separability
Log loss
Log score
Log-odds
Logistic regression
Loss function
M
Margin
Maximum likelihood estimation
Mini-batch
Model bias
Model capacity
Momentum
Multiclass perceptron
Multinomial naive Bayes
N
Naive Bayes
Numerical gradient check
O
One-hot encoding
Overfitting
P
Partial derivative
Perceptron
Posterior probability
Pseudo-count
R
Regression
Regularization
ReLU
S
Sigmoid
Smoothing strength
Softmax
Standardization
Stochastic gradient descent
Supervised learning
Symmetry problem
T
Test set
Token
Training curve
U
Underfitting
Universal approximation
V
Vanishing gradients
Variance
Vocabulary
Z
Zero-count problem
- 1Intelligent Agents
- 2Uninformed and Informed Search
- 3Constraint Satisfaction Problems
- 4Adversarial Search
- 5Logical Agents and Planning
- 6Bayesian Networks
- 7Hidden Markov Models
- 8Reinforcement Learning
- 9Supervised Learning and Neural Networks
- 10AI Ethics
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.