G検定 · LESSON 4

Elemental technologies of deep learning16%(当サイト設定) · 7 topics

Learn convolution layers, normalization layers, pooling layers and skip connections, recurrent layers, attention, autoencoders and data augmentation.

4.1Fully connected and convolution layers

Fully connected and convolution layers (kernel, stride, padding, feature map, dilated convolution, depthwise separable convolution)

Concept

A fully connected layer connects every input to every output. A convolution layer slides a small filter (kernel) over the image, extracting local features to make a feature map. Stride is the step the filter moves; padding adds values (usually 0) around the image to adjust output size. Output size is (input + 2×padding − kernel) ÷ stride + 1. Dilated convolution spaces out the filter to see a wider area. Depthwise separable convolution splits into per-channel convolution and 1×1 convolution to cut computation (MobileNet).

How it works / steps

  1. Be able to use the output size formula
  2. Understand why convolution has fewer parameters than full connection (weight sharing)
  3. Use depthwise separable convolution for lightweight models

Workplace example

Convolving a 32×32 image with a 3×3 kernel, stride 1 and padding 1 gives a 32×32 output.

Common confusions and exam tips

Mini quiz

Q1. Which best explains why convolution layers suit images better than fully connected layers?

  1. They compute after rearranging the image into one vector, so vertical and horizontal position relationships need not be considered
  2. They perform only fixed computations without weights, so training takes no time at all
  3. They connect every input to every output, so they always learn relationships between distant positions from the first layer
  4. They extract local features with filters that share weights, so few parameters are needed
Show answer and explanation

Answer: D They extract local features with filters that share weights, so few parameters are needed

Convolution handles spatial structure with few parameters through weight sharing and local connections. Fully connected layers flatten the image and lose positional relationships.

Q2. What is the size of the output feature map when convolving a 32×32 input image with a 5×5 filter, stride 1 and padding 0?

  1. 27×27
  2. 28×28
  3. 32×32
  4. 30×30
Show answer and explanation

Answer: B 28×28

(32 − 5 + 2×0)/1 + 1 = 28. Padding of 2 keeps 32×32.

Reference links

4.2Normalization layers

Normalization layers (batch, layer, instance and group normalization)

Concept

Normalization layers tidy the distribution of layer outputs, making training stable and fast. Batch normalization normalizes each feature within a mini-batch; layer normalization normalizes all features within one sample (used in Transformers). Instance normalization works per sample and per channel (used in style transfer); group normalization splits channels into groups and stays stable even with small batches.

How it works / steps

  1. Distinguish the unit of normalization (batch, sample, channel, group)
  2. With small batches, consider layer or group normalization
  3. Use layer normalization for Transformers

Workplace example

In object detection training where GPU memory allows a batch size of only 2, replace batch normalization with group normalization to stabilize training.

Common confusions and exam tips

Mini quiz

Q1. You are choosing a normalization layer method. In style transfer, you want to normalize per channel of each single image, removing per-image contrast differences. Which fits best?

  1. Group normalization
  2. Instance normalization
  3. Layer normalization
  4. Batch normalization
Show answer and explanation

Answer: B Instance normalization

Instance normalization is common in style transfer. (Deciding point: per sample, per channel.)

Q2. You are choosing a normalization layer method. In object detection training, GPU memory only allows mini-batches of 2, so you want to normalize by splitting the channels within a sample into groups. Which fits best?

  1. Instance normalization
  2. Batch normalization
  3. Group normalization
  4. Layer normalization
Show answer and explanation

Answer: C Group normalization

Group normalization doesn't depend on batch size and sits between layer and instance normalization. (Deciding point: channel groups usable with small batches.)

Reference links

4.3Pooling layers and skip connections

Pooling layers (max pooling, global average pooling) and skip connections (ResNet)

Concept

Pooling layers shrink feature maps and improve robustness to small shifts. Max pooling takes a region's maximum; average pooling takes its mean. There are no learnable parameters. Global average pooling takes the mean of each channel's whole feature map and replaces fully connected layers to reduce parameters. Skip connections add input to output, skipping layers; introduced in ResNet, they made training very deep networks possible.

How it works / steps

  1. Confirm that pooling has no parameters
  2. Reduce fully connected parameters with global average pooling
  3. Prevent vanishing gradients in deep networks with skip connections

Workplace example

Replace the large fully connected final layer of an image classifier with global average pooling, reducing parameters and curbing overfitting.

Common confusions and exam tips

Mini quiz

Q1. Which CNN layer shrinks feature maps by taking the max or average of small regions, adding robustness to small shifts?

  1. Fully connected layer
  2. Convolutional layer
  3. Batch normalization layer
  4. Pooling layer
Show answer and explanation

Answer: D Pooling layer

Max pooling and average pooling have no learnable parameters. The first option is a skip connection. [Other options] Convolutional layers extract features with learned filters. Fully connected layers link all units. Batch normalization aligns input distributions.

Q2. Which is the most appropriate benefit of global average pooling (GAP)?

  1. Averaging each feature map into one value replaces fully connected layers and cuts parameters
  2. It enlarges feature maps back to the original image size so each pixel can be classified
  3. It keeps only the maximum in each feature map and records where the most salient part is
  4. It adjusts the input image's average brightness and can replace data augmentation
Show answer and explanation

Answer: A Averaging each feature map into one value replaces fully connected layers and cuts parameters

GAP is used in GoogLeNet, ResNet and others, and also helps curb overfitting. It is also used in CAM.

Reference links

4.4Recurrent layers

Recurrent layers (RNN, BPTT, LSTM, GRU, bidirectional RNN, teacher forcing, Elman network)

Concept

An RNN (recurrent neural network) passes the previous time step's hidden state to the next, handling time series and text. It is trained with backpropagation unrolled through time (BPTT), but vanishing gradients occur on long sequences. LSTM keeps long-term dependencies with input, forget and output gates and a cell; GRU simplifies LSTM with two gates, reset and update. A bidirectional RNN uses information from both past and future. Teacher forcing feeds the previous step's correct answer as the next input during training. The Elman network is an early RNN that feeds hidden layer output back as the next step's input.

How it works / steps

  1. Understand why RNN-type models are used for sequence data
  2. Organize the roles of LSTM's gates
  3. Consider a bidirectional RNN when the whole sentence is available

Workplace example

To extract named entities (people, places) from text using context on both sides, use a bidirectional LSTM.

Common confusions and exam tips

Mini quiz

Q1. Which best describes an RNN (recurrent neural network)?

  1. It uses the previous time step's hidden state in the next step's computation, handling sequence data
  2. It extracts local image features with filters for recognition robust to shifts
  3. It learns to compress input into a low-dimensional latent representation and restore the original
  4. It pits a generator and a discriminator against each other to generate realistic data
Show answer and explanation

Answer: A It uses the previous time step's hidden state in the next step's computation, handling sequence data

An RNN is unrolled through time and trained with BPTT (backpropagation through time). A simple RNN is also called an Elman network.

Q2. You are choosing a sequence data model. In named entity extraction, you want each word's judgment to use both the context before and after it (the whole sentence is available in advance). Which fits best?

  1. LSTM
  2. Transformer
  3. GRU
  4. Bidirectional RNN
Show answer and explanation

Answer: D Bidirectional RNN

A bidirectional RNN combines forward and backward RNNs. It can't be used for real-time prediction. (Deciding point: context in both directions.)

Reference links

4.5Attention

Attention (Seq2Seq, Self-Attention, Source-Target Attention, Multi-Head Attention, Transformer, positional encoding, query/key/value)

Concept

Seq2Seq is a model where an encoder handles the input sequence and a decoder the output sequence (machine translation). Attention uses weights to decide where in the input to focus at each output step. Weights are computed from query-key similarity, and a weighted sum of values is taken. Source-Target Attention computes relations between input and output; Self-Attention computes relations within the same sequence. Multi-Head Attention runs several attentions in parallel. The Transformer uses only attention, no RNN, enabling parallel computation. Word order is added with positional encoding.

How it works / steps

  1. Understand the roles of query, key and value
  2. Distinguish Self-Attention from Source-Target Attention
  3. Understand why Transformers need positional encoding

Workplace example

In machine translation, Self-Attention judges whether “bank” means a financial bank or a riverbank from its relation to words like “money” in the sentence.

Common confusions and exam tips

Mini quiz

Q1. You are choosing a sequence data model. Without RNNs, you want to compute relations among all words in parallel with Self-Attention to train fast on long text. Which fits best?

  1. Bidirectional RNN
  2. GRU
  3. Transformer
  4. LSTM
Show answer and explanation

Answer: C Transformer

The Transformer has no recurrence, so it computes in parallel and captures long dependencies easily. (Deciding point: dropping recurrence for parallel attention.)

Q2. When training a translation Seq2Seq model, which method feeds the correct word, not the model's previous output, as the decoder's next input?

  1. Scheduled sampling
  2. Teacher forcing
  3. Knowledge distillation
  4. Beam search
Show answer and explanation

Answer: B Teacher forcing

Teacher forcing stabilizes training, but at inference the model uses its own outputs, so a gap between training and inference conditions (exposure bias) can arise. The third option is distillation. [Other options] Beam search is an inference-time search. Distillation trains a small model on a large model's output. Scheduled sampling switches between ground truth and model output to ease teacher forcing's exposure bias.

Reference links

4.6Autoencoders

Autoencoders (stacked autoencoders, VAE, VQ-VAE and β-VAE)

Concept

An autoencoder learns to compress input to low dimensions (encode) and restore it (decode), obtaining data features (latent representations). Stacked autoencoders, layered many deep, were used for pretraining. A VAE (variational autoencoder) learns latent variables as probability distributions and can generate new data. VQ-VAE represents latents as discrete vectors (a codebook); β-VAE is tuned so latent elements carry independent meanings (disentangling).

How it works / steps

  1. Understand the mechanism of learning so output matches input
  2. Use a VAE for generation
  3. In anomaly detection, treat data with large reconstruction error as anomalous

Workplace example

Train an autoencoder only on images of normal factory products and detect products with large reconstruction error as defect candidates.

Common confusions and exam tips

Mini quiz

Q1. You want a model translating Japanese sentences into English sentences of different length. Which basic architecture fits best?

  1. Seq2Seq, encoding the input sequence and generating the output sequence with a decoder
  2. An autoencoder compressing input and reconstructing the same input
  3. A classifier taking two sentences and judging if they mean the same
  4. A sequence labeling model assigning one label per input step
Show answer and explanation

Answer: A Seq2Seq, encoding the input sequence and generating the output sequence with a decoder

Input and output lengths may differ. Attention was introduced to overcome the limit of packing information into a fixed-length vector. [Other options] Sequence labeling keeps input and output length equal. Pair classification doesn't generate text. Autoencoders learn to reconstruct the same input.

Q2. Which best describes an autoencoder?

  1. A model that pits a generator against a discriminator to generate indistinguishable data
  2. A model that learns to compress input to a latent representation and restore the original input
  3. A reinforcement learning model that learns a policy maximizing reward from states and actions
  4. A classification model that uses labels and learns to predict the class of input images
Show answer and explanation

Answer: B A model that learns to compress input to a latent representation and restore the original input

It needs no labels and is used for dimensionality reduction, anomaly detection (large reconstruction error = anomaly) and denoising. Stacked autoencoders were once used for pretraining.

Reference links

4.7Data augmentation

Data augmentation (Crop, Flip, Rotate, Cutout, Random Erasing, Mixup, CutMix, RandAugment, paraphrasing)

Concept

Data augmentation transforms training data to increase its volume and variety, raising generalization. For images there are Crop, Flip and Rotate; Cutout and Random Erasing, which hide parts; Mixup (overlaying whole images) and CutMix (cutting and pasting a part), which mix two images; and RandAugment, which picks transform combinations automatically. For text, rewording (paraphrasing) and similar are used.

How it works / steps

  1. Choose transforms that don't break the task's meaning
  2. Apply augmentation to training data only
  3. Tune augmentation strength on validation data

Workplace example

In digit recognition, vertical flips swap “6” and “9” and break meaning, so use no flips — only small rotations and scaling.

Common confusions and exam tips

Mini quiz

Q1. You are choosing a data augmentation method. You want to cut a region from one image, paste it at the same position in another, and mix labels by area ratio. Which fits best?

  1. Mixup
  2. Cutout (Random Erasing)
  3. CutMix
  4. Paraphrasing
Show answer and explanation

Answer: C CutMix

CutMix combines the ideas of Cutout and Mixup. (Deciding point: cut and paste a part, mix labels by area.)

Q2. You are choosing a data augmentation method. To add text classification data, you want to create sentences with different wording but the same meaning. Which fits best?

  1. CutMix
  2. Paraphrasing
  3. Mixup
  4. Cutout (Random Erasing)
Show answer and explanation

Answer: B Paraphrasing

Paraphrasing is data augmentation for natural language. Noising, which adds noise, also exists. (Deciding point: rewording text.)

Reference links

Lessons are written by this site based on public information and do not guarantee exam content. Product specifications change, so check the latest information at the reference links.

Notes (unofficial, original questions, no pass guarantee)