3-1How AI Works
Back to the Educator Tips on the 3-1 page
Check question answers and scoring criteria
Q1. Using the word "feature," distinguish machine learning from deep learning in one sentence each.
- Model answer: In machine learning (the traditional approach), people choose the features, and the machine learns the weight to multiply each feature by. In deep learning, the machine learns everything from the raw data up to the features.
- Scoring (3 points)
- 2 points: Distinguishes the two approaches by "who chooses the features."
- 1 point: Mentions that deep learning is itself a branch of machine learning, or gives an example (3 weights vs. 1,741).
- Deduction: Writing "in deep learning, people do nothing" loses 1 point. People still decide the data and the model structure.
Q2. The training data contains "lighting gets darker" scenes, so why does feature A still get those scenes wrong?
- Model answer: Converted to feature A (area change, center shift), a lighting scene becomes a point with "a large increase in area and no change in center." This point lies on the same side as approaching, only farther out. A single straight line cannot separate it from approaching. The information needed to tell them apart was lost when the scene was reduced to 2 numbers, so adding more data does not fix it.
- Scoring (3 points)
- 1 point: On the feature plane, lighting scenes lie on the approaching side.
- 1 point: A single straight line (a linear classifier) cannot separate them.
- 1 point: The information was already lost at the feature-making stage. The fix is to change the features, not to add data.
Q3. Which human sense goes straight to the cerebral cortex without passing through the thalamus?
- Answer: Smell (olfactory epithelium → olfactory bulb → piriform cortex). 1 point.
- Good to add: From the piriform cortex to the orbitofrontal cortex, there is also a route that passes through the thalamus (Sela et al., 2009).
Q4. What do the fruit fly's LPLC2 and feature B from Section 3 have in common?
- Model answer: Both distinguish "an object growing in all directions" from "simply getting darker." LPLC2 does not respond to darkening without motion (Klapoetke et al., 2017). The difference is how they came to be. Feature B was designed by people, while LPLC2 is a circuit formed during development.
- Scoring (2 points): 1 point for the similarity, 1 point for the difference.
Q5. What is wrong with the judgment "We got 100% accuracy on the training data, so it will work well in the field too"?
- Model answer: The model can fail when it meets situations that were not in the training data. "No lighting changes" in Section 4 is an example. Training loss went down to 0.011, yet the model got 0 out of 20 lighting scenes right. It even said "avoid" with probability 0.99 for those scenes. You should measure skill on test data the model has never seen, and check whether the situations that will occur in the field are included in the training data.
- Scoring (3 points)
- 1 point: Distinguishes training performance from real-world performance.
- 1 point: Identifies the cause: situations not present in the data.
- 1 point: Suggests at least one countermeasure (test data, collecting field data, monitoring).
Sample answers for the Colab assignments
Basic assignment: add "approaching at an angle"
- Add a new kind of scene to
make_episodein Code 1. Example: the shadow grows while its center moves 3–5 cells. Set the label to 1 (must avoid). - Expected results
- Feature A: When the center shift is large, it is classified as "passing by." Accuracy is likely to drop.
- Feature B: The edge gets longer, so it is mostly right.
- Neural network: If these scenes are in the training data it gets them right; if not, it gets some wrong.
- Scoring points
- There is a results table.
- Explains the reason in terms of "the information the features hold" and "the situations the data holds."
- The actual numbers vary with the seed, so judge the interpretation, not the numbers themselves.
Challenge assignment: my own work data
- A good answer has the following.
- Three features and the reasoning behind them (domain knowledge).
- A graph comparing results by number of training examples.
- A conclusion based on data size, such as "the feature approach when examples are few, the neural network approach when there are enough."
- The test data was used only once, at the end.
- Common mistakes
- Mixing test data information into the feature calculation (data leakage).
- Looking only at accuracy and not at precision and recall (for imbalanced data; 3-2 Section 9).
Frequently asked questions in class
- "So is deep learning worse than machine learning?"
- No. It depends on the problem and the amount of data.
- For data like photos, sounds and text, where features are hard to put into words, deep learning is much stronger.
- The scenes on this page were made simple on purpose, so people could easily think of good features.
- "Does the human brain do backpropagation too?"
- This has not been confirmed. Hypotheses that the brain could do something similar by other means are being studied (Lillicrap et al., 2020).
- "Why are the browser numbers slightly different from the Colab numbers?"
- The two environments use different random number generators, so the scenes differ slightly.
- The accuracy of feature A is 86.9% in the browser (it also misses one approaching scene) and 87.5% in Colab.
- The conclusion is the same. In both environments, every lighting scene is wrong.
3-2Building Blocks of Neural Networks
Back to the Educator Tips on the 3-2 page
Check question answers and scoring criteria
Q1. If you stack 10 hidden layers in a neural network without activation functions, what kind of boundary can it draw? (2 points)
- Answer: Only a single straight line (a plane in higher dimensions).
- Scoring: 1 point for the conclusion. 1 point for the reason: combining several linear transformations still gives one linear transformation (W₂W₁x = Wx).
Q2. Why does using ReLU instead of sigmoid reduce vanishing gradients? (2 points)
- Answer: The sigmoid's gradient is at most 0.25, so it shrinks quickly as it is multiplied layer by layer. ReLU's gradient is 1 in the positive range, so it does not shrink as it flows backward.
- Scoring: 1 point for comparing 0.25 and 1, 1 point for explaining that "it shrinks because it is multiplied." It is good to add that the gradient is 0 in the negative range (dead neurons).
Q3. If the label is 1 and the prediction is 0.41, what are the MSE loss and ∂L/∂y? (2 points)
- Answer: L = (1 − 0.41)² = 0.3481 ≈ 0.35, ∂L/∂y = −2 × (1 − 0.41) = −1.18.
- Scoring: 1 point each. ∂L/∂y must have the correct sign.
Q4. Training loss keeps going down, but validation loss starts rising at some point. What is happening, and what should you do? (3 points)
- Answer: Overfitting.
- Scoring: 1 point for diagnosing overfitting, 1 point for early stopping (using the model from the point where validation loss was lowest), 1 point for at least one of dropout, weight decay, or more data.
Q5. In an inspection with a 10% defect rate, what are the accuracy and recall of a model that answers "all normal"? (2 points)
- Answer: Accuracy 90%, recall 0%.
- Scoring: 1 point each. It is good to add "with imbalanced data, you must not look at accuracy alone."
Sample answers for the Colab assignments
Basic assignment: tanh → ReLU, 4, 16 and 64 hidden neurons
- Two lines need to change. Change the activation function to max(0, z) and its derivative to "1 if z > 0, else 0."
- Run the code and put the results in a table. Adding neurons usually raises training accuracy, but from some point validation accuracy may stop rising or even fall.
- Scoring points: Check whether the setting was chosen by validation accuracy (choosing by training accuracy loses points) and whether the reason is explained in connection with overfitting.
Challenge assignment: 6:2:2 evaluation on my own work data
- Train only on the training data, choose settings and the threshold with the validation data, and use the test data only once, at the end.
- Whether a threshold of 0.5 is right depends on business costs. For example, if missing a defect is costly, lower the threshold to raise recall, and also report the resulting increase in false alarms (lower precision).
- Scoring points: Check whether all three metrics are reported and whether the reasoning for the threshold fits the business situation. Make sure data containing personal information was either not used or was anonymized.
3-3Images and CNNs
Back to the Educator Tips on the 3-3 page
Check question answers and scoring criteria
Q1. If you feed a 224×224 color photo into an MLP with 1,000 hidden neurons, how many weights does the first layer have? (excluding biases)
- Answer: 224 × 224 × 3 = 150,528, × 1,000 = 150,528,000 (about 150 million).
- Good to add: A convolution layer with 64 3×3 color filters has 3 × 3 × 3 × 64 = 1,728 (1,792 including biases).
- Scoring (2 points): 1 point for the formula, 1 point for the answer. Leaving out the 3 channels loses 1 point.
Q2. If you apply a 3×3 filter to a 6×6 input with no padding and a stride of 1, what is the output size?
- Answer: (6 − 3 + 1) × (6 − 3 + 1) = 4×4. 1 point.
Q3. Show by calculation why the output is −3 when the vertical edge filter from Section 5 is placed at the top-left position.
- Model answer: The second row of the overlapping patch is [0, 3, 3], and each row of the filter is [1, 0, −1]. 0×1 + 3×0 + 3×(−1) = −3. The first and third rows are all 0.
- Scoring (2 points): 1 point for picking the correct overlapping patch, 1 point for correctly multiplying cell by cell and adding.
Q4. What are the max pooling and average pooling values of the 2×2 window [6, 3, 0, 3]?
- Answer: Max 6, average (6 + 3 + 0 + 3) / 4 = 3. 1 point each.
Q5. If you shuffle the pixels with a fixed rule and train from scratch, which drops more, the MLP or the CNN, and why?
- Model answer: The CNN drops more.
- The CNN builds the assumption "nearby pixels are related" into its structure (3×3 filters, pooling). Shuffling breaks this assumption.
- The MLP never used the positional relationships between pixels in the first place, so it stays about the same.
- Actual results: In the browser, MLP 92.7% → 91.3%, CNN 78.7% → 67.3%. Colab averages over 3 seeds: MLP 88.4% → 90.0%, CNN 80.2% → 65.8%.
- Scoring (3 points)
- 1 point: The result (the CNN drops more).
- 1 point: Explains the CNN's assumption (neighbor relationships).
- 1 point: States the condition precisely (shuffled with a fixed rule and trained from scratch). Do not give this point for "feeding shuffled images into a trained model."
Sample answers for the Colab assignments
Basic assignment: add a diagonal filter
- Example filter:
[[0,1,1],[-1,0,1],[-1,-1,0]](a diagonal boundary, bright at the top right and dark at the bottom left). -
The 4×4 output computed with Code 1:
3 0 0 -6 6 6 6 0 0 0 0 0 3 0 -3 0 -
The maximum is 6, appearing in row 2, columns 1, 2 and 3. This is not the slanted stroke but the boundary just below the top bar of the 7. The filter responds to places that are "bright above and to the right, dark below and to the left," so it also responds strongly to horizontal boundaries.
- When the expectation (the diagonal stroke) and the actual result differ like this, a good answer explains why using the numbers as evidence. The lesson of this assignment is that guessing where a filter responds from its name alone can be wrong.
- Scoring points
- Connects the arrangement of the filter's numbers to where it responds.
- Quotes numbers computed with the code.
Challenge assignment: data augmentation
- Expected trend
- Mixing images shifted by 1–2 cells into the training images raises both models' accuracy at 1–2 cell shifts.
- The MLP also improves a lot, because it memorizes the shifted positions from the data.
- At a 3-cell shift, which was not in training, the CNN is still expected to drop less. Judge by the actual numbers from the student's own run.
- Example of a good conclusion: "Structure (weight sharing, pooling) makes a model less sensitive to small shifts even without data, while augmentation only makes it robust to the range of shifts it was shown. In practice, both are used together."
Frequently asked questions in class
- "The CNN scores lower than the MLP on centered images?"
- Right. When training and test positions are the same and the data is small, as on this page, the MLP can win. The CNN has 4.5 times fewer parameters.
- The CNN's strengths are fewer parameters and robustness to shifts. It pays off most on data where positions vary, like real photos.
- "Doesn't a CNN recognize things the same way even when their position changes?"
- No. Shift by 2 cells and the CNN also drops, 78.7% → 69.3% (in the browser).
- Even large CNNs can change their answer when the input shifts by a few pixels (Azulay & Weiss, 2019). "Relatively less sensitive" is the accurate statement.
- "Why is the MLP higher at a 1-cell shift?"
- It is noise from a small experiment: one seed and 150 test images.
- In the Colab averages over 3 seeds, the CNN (64.2%) beat the MLP (54.7%) at 1 cell too. Teach along with this that conclusions should be drawn from repeated runs.
3-4Speech
Back to the Educator Tips on the 3-4 page
Check questions
- Q1 (1 point): 4,000 Hz.
- Q2 (1 point): 3 Hz.
- Q3 (2 points): About 48 dB (theoretical 49.92 → 98.08 dB). 1 point for the formula, 1 point for the value.
- Q4 (2 points): 98 frames. (8,000 − 200) ÷ 80 = 97.5 → round down to 97, + 1 = 98. Answering "97" gets 1 point.
- Q5 (2 points): 1,960, about one quarter.
Sample assignment answers
- Basic (NMEL 40, FRAME 400): The matrix becomes (fewer frames) × 40. A longer window gives finer frequency detail, but the number of frames drops and changes over time get blurred.
- Scoring: Check whether the change in the number of frames was confirmed by calculation.
- Challenge (your own recording): Even if you record the same sound twice, the correlation is not 1. Distance, noise, volume and speaking speed make the difference.
- Check that consent for personal information was obtained.
3-5Text
Back to the Educator Tips on the 3-5 page
Check questions
- Q1 (1 point): 0xAC01 ("각").
- Q2 (2 points): 14 bytes = 9 + 1 + 4.
- Q3 (2 points): Using word frequencies as weights, count how often each pair of adjacent pieces appears, and merge the most frequent pair.
- Q4 (2 points): Word-level gives "모름" (unknown); BPE gives ["초파리", "들", "이"].
- Q5 (2 points): Both are {dog:1, bites:1, man:1}. Position information is needed.
Sample assignment answers
- Basic (adding butterfly sentences): "나비는" (butterfly) is expected to move closer to words like "꿀벌은" (honeybee) and "초파리는" (fruit fly), which appear in the same position and with the same words (꽃을, 날개가).
- Check the values by running the code. Instructors should run it once before class.
- Challenge (number of merges): More merges make the vocabulary larger and reduce the number of tokens per sentence.
- If it is too large, rare tokens increase and there is not enough training material for them.
- If it is too small, sentences get longer and computation increases.
- Check whether the evidence is presented in a table.
3-6Time Series & Stock Prices
Back to the Educator Tips on the 3-6 page
Check questions
- Q1 (1 point): 500 pairs.
- Q2 (2 points): 10 times. The first training uses 300 pairs, the last 480 pairs.
- Q3 (1 point): About 4 percentage points.
- Q4 (2 points): Selection bias and overfitting. Use the test period only once, at the end.
- Q5 (3 points): Reports the results as numbers, as they are (1 point); states the data and setting conditions (1 point); presents the limits of generalization and the next experiment (1 point).
Sample assignment answers
- Basic (normalizing over the whole period): The numbers change slightly. The direction depends on the data.
- The key point is to explain that, whether results get better or worse, "the evaluation used future information, so it cannot be trusted."
- Challenge (predicting the size of changes): In Section 2, the autocorrelation of absolute returns was larger than that of returns (4/10 vs. 0/10). So you can expect relatively more room for improvement over the baseline.
- Have students run it and report actual results with 3 or more seeds.
Note for running the class. At the start and end of class, state clearly that "this is an educational example, not investment advice." If a student asks for buy or sell judgments on a specific stock, tell them it is outside the scope of this page.
3-7Sequence Models
Back to the Educator Tips on the 3-7 page
Check question answers and scoring criteria
Q1. If you average a sequence and feed it into a feedforward neural network, what information is lost?
- Model answer: The order is lost. 100 → 110 → 120 and 120 → 110 → 100 both have an average of 110.
- Scoring (2 points): 1 point for saying "order," 1 point for giving an example.
Q2. If you feed 1, 0, 0 into h_t = tanh(x_t + 0.9·h_(t−1)), what are h_1 and h_2?
- Answer: h_1 = tanh(1) ≈ 0.762, h_2 = tanh(0.686) ≈ 0.595.
- Scoring (2 points): 1 point each. Accept rounding within ±0.002.
Q3. If f = σ(5) ≈ 0.9933 and the input gate is fully closed, how many times the initial value is the cell state at step 20?
- Answer: 0.9933¹⁹ ≈ 0.880 times.
- Good to add: The actual value in Section 5 (0.988 → 0.864, about 0.875 times) is slightly smaller because the input gate is open by 0.007, letting the distractor signals (ten −1s and nine +1s) leak in.
- Scoring (2 points): 1 point for the correct number of multiplications (19), 1 point for the correct value. Writing the 20th power (0.874) gets only 1 point.
Q4. With 16 hidden units and 1 input, how many parameters do the recurrent layers of SimpleRNN, LSTM and GRU (textbook formula) have?
- Answer: One set = 16 × 17 + 16 = 288.
- SimpleRNN: 288
- LSTM: 4 × 288 = 1,152
- GRU (textbook formula): 3 × 288 = 864
- Good to add: The default Keras GRU adds 48 more biases for 912. This matches the output of Code 2.
- Scoring (3 points): 1 point each.
Q5. An LSTM failed at T = 100. Can you conclude that "LSTMs cannot hold long memories"?
- Model answer: No.
- With suitably chosen weights, as in Section 5, an LSTM can hold long memories.
- The failure means that gradient descent did not find those weights within 30 epochs.
- You can only draw a conclusion after changing training time, learning rate and data size, and repeating the experiment with several seeds.
- Scoring (3 points)
- 1 point: Distinguishes the capacity of the architecture from the outcome of training.
- 1 point: Suggests alternative experiments.
- 1 point: Mentions the need for repeated (multi-seed) experiments.
Sample answers for the Colab assignments
Basic assignment: keep the input gate always open (i = σ(5))
- Expected result: At every step, 0.993 × g(±0.995) is added to the cell state. The cell state swings widely following the latest distractor signals, and even if you flip the first signal, the value 20 steps later ends up almost the same.
- Students must quote values computed with the code. Instructors should run it once themselves before class to check the numbers.
- Example of a good conclusion: "The input gate decides 'when to write.' If it writes at any time, old signals get overwritten by new ones."
Challenge assignment: turn the T = 100 failure into success
- Things worth trying
- More epochs (e.g. 100 or more)
- A different learning rate (0.001, 0.01)
- More training data
- Training on short sequences first and gradually lengthening them (curriculum learning)
- A different hidden size
- You only know the results by running it. Have students make a table with 3 or more seeds, and if success or failure depends on the seed, report that as a result too.
- Scoring points: Check whether changes were compared one at a time. Also check that results were not cherry-picked.
Frequently asked questions in class
- "Textbooks say RNNs fail on long sequences, so why did SimpleRNN succeed at T = 50?"
- The task is relatively simple (remember only the first step), and depending on the initialization, memory can last quite a while. Keras recurrent layers initialize the recurrent weights as an orthogonal matrix by default.
- What matters is not forcing experimental results to match textbook statements, but stating the conditions and reporting the results as they are.
- "Why did GRU fail at T = 50?"
- With this setting (30 epochs, learning rate 0.005), both seeds stayed at chance level. The cause cannot be determined from this experiment alone. Connect it to the challenge assignment.
- "Did the LSTM have a forget gate from the start?"
- No. It was not in the original 1997 paper; Gers et al. added it in a 2000 paper (presented at a conference in 1999).
3-8Attention & Transformers
Back to the Educator Tips on the 3-8 page
Check question answers and scoring criteria
Q1. With q = [2, 0.4], k = [2, 0] and d_k = 2, what is the score q·k / √d_k?
- Answer: q·k = 4, 4 / √2 ≈ 2.828.
- Scoring (2 points): 1 point for the dot product, 1 point for the division.
Q2. What is the softmax of the scores [1.98, 1.98, 2.772], and the result of mixing V = [10,0], [0,10], [6,6]?
- Answer: Attention ≈ [0.238, 0.238, 0.525], result ≈ [5.53, 5.53]. The output of Code 1 is [5.525, 5.525].
- Scoring (3 points): 1 point for the softmax, 1 point for the weighted-sum formula, 1 point for the value. Accept ±0.01.
Q3. Using only self-attention without positional encoding, what happens to each word's output when the word order is shuffled?
- Model answer: It stays the same. Each word's output is determined only by comparisons with all the other words, and the set of words compared is the same regardless of order. In Code 1, the difference was 1e-16, i.e. at the level of rounding error.
- Scoring (2 points): 1 point for the result, 1 point for the reason.
Q4. How many parameters does a multi-head attention layer with d = 512 have, and what changes if you switch to 16 heads?
- Answer: 4 × 512² + 4 × 512 = 1,050,624. It stays the same when the number of heads changes (only the head width goes from 64 → 32).
- Scoring (2 points): 1 point for the value, 1 point for "does not change" and the reason.
Q5. If the length goes from 4,096 → 8,192, how does the number of attention scores change?
- Answer: 4 times (16,777,216 → 67,108,864). 1 point.
Sample answers for the Colab assignments
Basic assignment: don't divide by √d_k
- In the library example, not dividing makes the scores √2 times larger, so attention leans further toward one side.
- Make the vectors 10 times larger and the scores become 100 times larger, so softmax gives almost 1 to a single position. Then the gradients for the other positions get close to 0, making training difficult.
- Have students quote numbers they computed with the code.
Challenge assignment: remove the positional embedding
- Expected: Without position information, the first position cannot be distinguished from the others. So the model cannot single out the first position, and accuracy is expected to approach chance level. "Attention given to the first position" will also likely drop to around 1/T.
- Have students confirm the actual results by running it. Instructors should run it once themselves before class.
- Scoring points: Check whether the explanation connects to "shuffling the order gives the same result" from Section 6.
Frequently asked questions in class
- "Why are the LSTM numbers different from 3-7?"
- Code 2 in 3-8 rebuilt the model with a fixed input length (3-7 allowed any length). So the initial computation graph and random number consumption differ slightly.
- The T = 100 results are 48.9 / 47.2% in 3-7 and 50.6 / 57.4% in 3-8. The conclusion is the same: both are at chance level.
- "The Transformer won, so are LSTMs no longer used?"
- In this task the answer is "one value at the first position," which especially favors attention.
- Recurrent models are still used for real-time step-by-step processing or when data is scarce (3-7 Section 9).
- "How many parameters does the base model of the original paper have?"
- This page calculates and shows one block (3,152,384) by formula.