0% found this document useful (0 votes)
9 views15 pages

Advances in AI: RL, Audio Processing, GANs

Uploaded by

RstStt
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views15 pages

Advances in AI: RL, Audio Processing, GANs

Uploaded by

RstStt
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Course Title: Advances in Artificial Intelligence Course Code: AIML401

Examination: End Semester Examination Nov 2025

Programme: Integrated B. Tech. M. Tech DT

Name of the Examiner: Ravi Shankar

Sr. Model Answers Distribution of


No. Marks
Section A
1 Define Reinforcement Learning (RL) and distinguish it from supervised
and unsupervised learning. 6M
Sol: RL is a learning paradigm in which an agent interacts with an
environment and learns to take actions that maximize cumulative reward. The
agent receives feedback in the form of rewards or penalties, rather than
labeled examples, and improves its decisions through trial-and-error.
Distinction between RL, Supervised Learning, and Unsupervised Learning

Supervised Learning
• The model is trained using labeled data (input-output pairs).
• The objective is to learn a mapping from inputs to the correct outputs.
• Examples: classification, regression.

Unsupervised Learning
• The model is trained using unlabeled data.
• The objective is to discover hidden patterns or structures in the data.
• Examples: clustering, dimensionality reduction.

RL
• No labeled data is provided.
• Learning occurs by interacting with the environment.
• The model receives rewards or penalties and learns the optimal
action policy over time.
• Examples: game-playing agents, robotic control, autonomous
driving.
Summary Table
Unsupervised Reinforcement
Feature Supervised Learning
Learning Learning
Data No labels; reward
Labeled Unlabeled
Type signal
Find Maximize
Goal Predict output
structure/pattern cumulative reward
Feedback Direct (correct
None Reward/penalty
Type answer provided)
Learning Trial-and-error
Mapping function Pattern discovery
Style decision-making
2 (a) Define audio signal processing and explain its main objectives. 2M
Sol: Audio signal processing is the discipline concerned with the acquisition,
digitization, representation, analysis, and modification of acoustic waveforms
using mathematical and algorithmic techniques. It involves converting real-
world sound pressure waves into discrete-time signals through sampling,
quantization, and encoding, and subsequently applying digital signal
processing (DSP) operations for analysis, enhancement, transmission, and
synthesis. In its technical form, audio signal processing sits at the intersection
of acoustics, Fourier analysis, statistical modeling, and digital systems, where
the goal is to manipulate audio in its digitized form for reliable storage,
transmission, and interpretation.
The first objective is to convert an analog audio waveform,
𝑥(𝑡)
into a discrete-time signal
𝑥[𝑛] = 𝑥(𝑛𝑇𝑠 )
using a sampling period 𝑇𝑠 , ensuring:
➢ Compliance with the Nyquist sampling theorem
➢ Minimum aliasing through anti-aliasing filters
➢ High-resolution quantization for low distortion
This stage defines the fidelity of all downstream processing.
Once digitized, audio is analysed using mathematical transforms to reveal
spectral and temporal characteristics:
✓ DFT/FFT for spectral analysis
✓ STFT, Wavelet Transform, Cepstrum for time–frequency features
✓ Extraction of technical descriptors: MFCCs, pitch contours,
formants, zero-crossing rate, spectral centroid
This enables speech recognition, audio classification, and source
identification.
Digital Enhancement and Restoration
DSP algorithms aim to improve signal quality in the digital domain:
✓ Adaptive filtering for noise cancellation
✓ Linear prediction (LPC) for speech enhancement
✓ De-reverberation using inverse filtering
✓ Echo suppression via least-mean-square (LMS) algorithms
The objective is to maximize SNR and perceptual quality in real-time
systems.

4M

Sol: An analog audio signal contains frequency components up to 30 kHz.


Maximum frequency of the signal:
𝑓max = 30 kHz
(i) Minimum Sampling Frequency (Nyquist Rate)
According to the Nyquist Sampling Theorem:
To avoid aliasing, the sampling frequency must be at least twice the
maximum frequency in the signal:
𝑓𝑠 ≥ 2𝑓max
Substitute the value:
𝑓𝑠 ≥ 2 × 30 kHz
𝑓𝑠 = 60 kHz
So, the minimum sampling frequency required to avoid aliasing is 60 kHz.

(ii) Nyquist Interval (Sampling Period)


Sampling period is the reciprocal of the sampling frequency:
1
𝑇𝑠 =
𝑓𝑠
1
𝑇𝑠 =
60 × 103
𝑇𝑠 = 1.666 × 10−5 s
𝑇𝑠 ≈ 16.67 𝜇s
3 (a) What is the fundamental concept behind a Generative 2M
Adversarial Network (GAN)?
Sol: The fundamental concept behind a Generative Adversarial Network
(GAN) is a two-player adversarial learning framework in which two neural
networks, the Generator (G) and the Discriminator (D) are trained
simultaneously in a competitive (min-max) game.
• The Generator tries to produce synthetic data (e.g., images, audio,
text) that resembles real data.
• The Discriminator tries to distinguish between real samples (from
the dataset) and fake samples (produced by the generator).
Both networks improve by competing:
• The generator gets better at “fooling” the discriminator.
• The discriminator gets better at detecting fake data.
This adversarial process forces the generator to learn the underlying
probability distribution of the training data, enabling it to generate
highly realistic samples.
Formal Min–Max Objective
min⁡ max⁡ 𝑉(𝐷, 𝐺)
𝐺 𝐷
= 𝔼𝑥∼𝑝𝑑𝑎𝑡𝑎(𝑥) [log⁡ 𝐷(𝑥)] + 𝔼𝑧∼𝑝𝑧(𝑧) [log⁡(1
− 𝐷(𝐺(𝑧)))]

(b) Explain the roles of the generator and discriminator in a GAN.


Sol: A Generative Adversarial Network (GAN) consists of two core
components the Generator (G) and the Discriminator (D) that are trained
simultaneously in a competitive (adversarial) manner. Each component has a
distinct but complementary role, and their interaction drives the GAN
learning process.
Role of the Generator (G)
The generator is responsible for producing synthetic data that resembles the
real data distribution as closely as possible. It aims to generate samples that
are indistinguishable from real data.
How the Generator Works 4M
1. Input:
o The generator receives a random noise vector 𝑧drawn
from a simple distribution (Gaussian or uniform).
𝑧 ∼ 𝑝𝑧 (𝑧)

2. Transformation:
o It uses a neural network to transform this noise into a
structured data sample (image, audio, text, etc.).
o The transformation attempts to map the noise distribution
to the real data distribution 𝑝𝑑𝑎𝑡𝑎 (𝑥).
3. Objective:
o The generator tries to fool the discriminator into
classifying its output as real.
o During training, it updates its parameters to maximize:
log⁡(𝐷(𝐺(𝑧)))
meaning it wants the discriminator to output a probability close to 1 (real)
for generated samples.
4. Learning Behavior:
o The generator improves only when the discriminator
correctly or incorrectly identifies its fakes.
o Over time, it learns the complex patterns, structure, and
statistical properties of the real dataset.
Generator:
• Takes noise → generates fake data.
• Learns to approximate the real data distribution.
• Tries to fool the discriminator.
• Its success is measured by how realistic its outputs become.
Role of the Discriminator (D)
The discriminator acts as a binary classifier that distinguishes between:
• Real samples from the training dataset
• Fake samples produced by the generator
It ensures the generator does not drift away from generating realistic
content.
1. Input:
o It receives both real data samples 𝑥and generated samples 𝐺(𝑧).
2. Output:
o Produces a probability
𝐷(𝑥) ∈ [0,1]

where:
▪ 1 → real
▪ 0 → fake
3. Training Objective:
The discriminator tries to maximize:
log⁡(𝐷(𝑥)) + log⁡(1 − 𝐷(𝐺(𝑧)))

o It wants real samples to be classified as real (D(x) → 1)


o It wants fake samples to be classified as fake (D(G(z)) → 0)
4. Learning Behavior:
o As the generator improves, the discriminator must learn more subtle
features to distinguish real from fake.
o This creates an adversarial push-and-pull dynamic that drives the
learning of both networks.
In Summary (Discriminator):
• Acts as a critic or judge.
• Receives both real and generated data.
• Learns to classify data as real or fake.
• Guides the generator by providing error feedback.

Interaction Between Generator and Discriminator

The GAN training process is a min–max game:


Discriminator wants to maximize:
log⁡(𝐷(𝑥)) + log⁡(1 − 𝐷(𝐺(𝑧)))

Generator wants to minimize:


log⁡(1 − 𝐷(𝐺(𝑧)))

or equivalently maximize:
log⁡(𝐷(𝐺(𝑧)))

Together, they push each other to improve:


Component Goal Behaviour
Fool the Produces increasingly realistic
Generator
discriminator samples
Discriminator Detect fakes Learns finer discriminative features

This adversarial interaction eventually leads to an equilibrium where the


generator's output is so realistic that the discriminator cannot differentiate real
from fake with better than 50% probability.

Generator:
• Creates fake samples from random noise.
• Tries to mimic the real data distribution.
• Learns by trying to fool the discriminator.
Discriminator:
• Classifies inputs as real or fake.
• Provides feedback to the generator.
• Learns deeper representations to detect synthetic samples.

4 What are the key characteristics of the human vocal tract that influence 6M
speech signals?
Sol: The human vocal tract behaves as a dynamic, shape-varying acoustic
filter that significantly modifies the excitation generated by the vocal folds.
Its physical and physiological properties directly determine the spectral
structure, formant locations, resonance behaviour, and temporal variations
observed in speech signals.
The major characteristics are as follows:
1. Vocal Tract Shape and Length
The vocal tract is an irregular acoustic tube extending from the glottis to the
lips, and its effective length (≈16–18 cm) and continuously varying cross-
sectional shape determine the resonant behaviour of speech.
• Different articulatory configurations (tongue movement, jaw
opening, lip rounding) modify the acoustic transfer function.
• Changes in shape cause formant frequencies (F1, F2, F3...) to shift,
which uniquely identify vowels.
• Consonants arise from constrictions or closures at specific locations
(velar, alveolar, labial).
2. Resonances and Anti-Resonances
The vocal tract exhibits resonant frequencies where specific harmonic
components of the source are amplified.
• Formants: Peaks in the spectral envelope created by resonances of
the tract.
• Anti-resonances: Occur when side cavities (nasal or oral) trap
sound energy, creating spectral dips.
• These resonances determine the timbre, vowel identity, and
phoneme classification.
3. Dynamic Articulator Motion
The position of articulators (tongue, lips, teeth, velum) changes rapidly
during speech.
Key effects:
• Continuous time-variation causes coarticulation, where adjacent
phonemes influence each other.
• Dynamic transitions in formant trajectories carry important
phonetic and prosodic information.
• Temporal variations determine consonant–vowel transitions and
speech intelligibility.
4. Acoustic Coupling of Oral and Nasal Cavities
The velum controls whether the nasal cavity participates in speech
production.
• When the velum lowers, the nasal cavity forms an additional
resonant tract, leading to nasalized vowels and nasal consonants
(m, n, ŋ).
• The coupled oral–nasal tract creates:
o Extra resonances (nasal formants)
o Anti-resonances that attenuate specific frequency bands
This produces the characteristic spectral shape of nasal
speech.
5. Radiation Characteristics at the Lips
The lips behave as a high-pass filter, due to acoustic radiation into the air.
• Low-frequency components are attenuated; high-frequency
components are enhanced.
• This modifies the spectral tilt of the speech signal, making it more
intelligible.
6. Physiological Properties
The walls of the vocal tract are not rigid; they absorb and dissipate acoustic
energy.
• Soft tissues introduce frequency-dependent damping, reducing
higher formants.
• Absorption and viscous losses cause bandwidth widening and
lower spectral peaks.
These properties explain why real speech deviates from ideal tube-model
predictions.
7. Speaker-Specific Characteristics
Inter-speaker variations include:
• Vocal tract length (different for males, females, children)
• Oral cavity volume, tongue size, lip thickness
• Glottal excitation differences (pitch and spectral tilt)

5 Describe the architecture of a knowledge-based system with a neat 6M


diagram.

Sol: Knowledge-based agents (KBAs) are structured to integrate, process,


and apply knowledge for intelligent reasoning and decision-making. Their
architecture consists of three key components:
Knowledge Base
The knowledge base serves as a repository of facts, rules, and information.
This is where agents store structured data that supports reasoning processes.
For example, in a medical diagnostic agent, the knowledge base may contain
symptoms, diseases, and corresponding treatments.
Inference Engine
This component applies logical reasoning to the knowledge base, deriving
new conclusions or making decisions based on existing facts. For instance,
the inference engine can infer potential diseases from observed symptoms in
a patient.
Sensors and Actuators
Sensors allow agents to perceive their environment by collecting external
data, while actuators enable them to act upon that environment. For example,
in a robotics agent, sensors may detect obstacles, and actuators adjust their
movement accordingly.

Why Use a Knowledge Base?


A knowledge base provides a structured repository of information that enables
intelligent and informed decision-making. By organizing data into facts and
rules, it allows knowledge-based agents to reason and derive logical
conclusions efficiently.
Advantages:
• Ensures consistency and accuracy in decision-making.
• Reduces redundancy by storing reusable information.
• Enables quick retrieval of relevant data for problem-solving.
Use Cases:
• Medical Diagnosis: Agents analyze symptoms and suggest
treatments based on stored medical knowledge.
• Recommendation Systems: Deliver personalized suggestions using
user preferences and historical data.
• Customer Support: Provide instant, automated responses to common
queries, enhancing user experience.

Section B
6 (a) What is meant by an artificial neuron, and how does it mimic the 4M
biological neuron?
Sol: Biological neurons and artificial neurons have some similarities and
differences in their structure and function. Here are some of the main points
of comparison:
Structure: Biological neurons have a complex and organic structure,
consisting of dendrites, soma, axon, and synapses. Artificial neurons have a
simple and mathematical structure, consisting of inputs, weights, bias, and
activation function.
Function: Biological neurons process and transmit electrical and chemical
signals, using action potentials and neurotransmitters. Artificial neurons
process and transmit numerical values, using weighted sums and activation
functions.
Learning: Biological neurons learn and adapt through synaptic plasticity,
changing the strength and number of synapses based on experience and
stimuli. Artificial neurons learn and adapt through weight adjustment,
changing the value and number of weights based on error and feedback.
Efficiency: Biological neurons are highly efficient and parallel, processing
and transmitting signals at high speed and low energy consumption. Artificial
neurons are less efficient and sequential, requiring more time and power to
perform computations and communications.

ANN
Artificial neurons are usually organized into layers, forming a neural network.
The first layer receives the input data, the last layer produces the output, and
the intermediate layers are called hidden layers. Each layer performs a specific
transformation on the data, passing it to the next layer. The more layers and
neurons a neural network has, the more complex functions it can learn.
The input layer has three neurons, corresponding to three features of the data.
The hidden layer has four neurons, performing some computation on the input
data. The output layer has one neuron, producing the final prediction or
decision.
How do they work together?
The way neural networks work is by adjusting the weights of the connections
between the neurons based on the error of the network predictions compared
to the actual data. This is called the training process, where the network learns
from the data and improves its performance. The training process can be done
using various algorithms, such as gradient descent, backpropagation,
stochastic gradient descent, etc.
The goal of the training process is to minimize the error or loss function,
which measures how well the network fits the data. The lower the error or
loss, the better the network performs. The training process can be repeated
until the network reaches a satisfactory level of accuracy or meets some
predefined criteria.
Activation Functions Explained
One of the key components of artificial neurons is the activation function,
which determines if a neuron should be activated or not based on the input
signals. Activation functions introduce non-linearity into neural networks,
enabling them to solve complex problems beyond linear separability. Linear
separability means that the data can be separated by a straight line.
However, not all data sets are linearly separable. Some data sets are more
complex and require curved or nonlinear boundaries to separate them. This is
where activation functions come in handy. They allow the network to learn
nonlinear functions and create nonlinear boundaries. Different types of
activation functions serve various purposes depending on the network
architecture and the problem type. Some of the common activation functions
are:
Sigmoid: This function maps the input to a value between 0 and 1, creating a
smooth curve. It is useful for binary classification problems, such as
predicting whether an email is spam or not. However, it has some drawbacks,
such as being prone to saturation and vanishing gradients, meaning that the
network stops learning when the input is too large or too small.
ReLU: This function maps the input to either 0 or the input itself, creating a
linear and non-linear region. It is useful for speeding up the convergence and
avoiding the vanishing gradient problem. However, it has some drawbacks,
such as being prone to dying neurons, meaning that some neurons stop
responding to any input and become inactive.
Tanh: This function maps the input to a value between -1 and 1, creating a
symmetrical curve. It is useful for centring the data and creating a zero mean.
However, it has some drawbacks, such as being prone to saturation and
vanishing gradients, like the sigmoid function.

(b) Explain the biological motivation for neurocomputing and how it


has influenced modern AI.

Sol: Neurocomputing is a field of computer science and engineering that


focuses on developing computational models and systems inspired by the
structure and function of the biological nervous system, particularly the brain.
It fundamentally differs from traditional digital computing by employing
an adaptive, parallel processing paradigm that "learns" from data rather than
relying on explicit, step-by-step programming.
Core Concepts
• Artificial Neural Networks (ANNs): The central component of
6M
neurocomputing are ANNs, which are systems composed of simple
processing elements called artificial neurons or nodes.
• Interconnections and Weights: These artificial neurons are
interconnected with adjustable connection strengths, known as weights,
which are analogous to the synapses in a biological brain. The specific
pattern and strength of these connections determine how the network
processes information.
• Learning: The primary contribution of neurocomputing is algorithms
(such as backpropagation) that allow a neural network to be trained by
example. During training, the network adjusts its weights to minimize
the difference between its output and the desired output, learning from
experience and adapting its performance over time.
• Parallel Processing: Mirroring the brain's massive parallel structure,
neural networks perform computations simultaneously across many
nodes, making them highly efficient for complex tasks.
• Neuromorphic Hardware: This is a related engineering approach that
involves specialized hardware, such as neuromorphic chips and AI
accelerators (e.g., IBM's TrueNorth, Intel's Loihi), designed to
physically mimic the brain's architecture for improved energy
efficiency and speed in AI applications.
Applications
Neurocomputing is used to solve complex, intelligent problems across various
domains:
• Pattern Recognition & Classification: Facial and speech recognition,
medical image analysis, and handwriting recognition.

Natural Language Processing (NLP): Machine translation, chatbots,
and sentiment analysis.
• Robotics & Control Systems: Real-time navigation, motor control,
and object detection in autonomous systems.
• Finance: Stock market prediction, fraud detection, and risk
management.
• Data Analysis: Extracting insights and predicting outcomes from
large, complex datasets, such as in the prediction of oil prices.
Key Characteristics
Feature Description

Inspiration Biological neural networks in the human brain.

Processing Massively parallel and distributed.

Learning Learns from data and experience, not explicit


programming.

Handling Capable of working with incomplete, noisy,


Data and non-linear data.

Fault Can continue to function even if some


Tolerance components are damaged.

7 Differentiate between first- and second-generation knowledge-based 10M


systems in terms of:
- Architecture
- Knowledge representation
- Reasoning
- Performance
- Adaptability

Sol:
First-Generation KBS
Second-Generation KBS
Aspect (Classical Expert
(Modern Intelligent Systems)
Systems)
• Layered, modular, and
• Monolithic distributed architecture.
architecture. • Integration of multiple
• System components intelligent modules (e.g.,
1. Architecture
tightly coupled. learning, uncertainty handling,
• Often rule-based with planning).
limited modularity. • Supports agent-based and
blackboard architectures.
• Uses hybrid representation:
• Knowledge stored as
rules + frames + ontologies +
rigid IF–THEN rules.
probabilistic models.
• Symbolic and
• Knowledge encoded in
2. Knowledge deterministic
semantic networks, conceptual
Representation representations.
graphs, fuzzy sets, Bayesian
• Limited ability to
models, and ML models.
handle incomplete or
• Can model uncertainty and
uncertain data.
ambiguity.
• Purely symbolic • Mixed reasoning: symbolic +
reasoning. probabilistic + learning-based
• Uses simple forward inference.
3. Reasoning or backward chaining. • Includes non-monotonic
• Weak at handling reasoning, case-based
uncertain, noisy, or reasoning, neural inference,
dynamic data. fuzzy reasoning.
• Better suited for real-time and
complex domains.

• Higher efficiency due to


• Slow rule matching
modular design and advanced
due to large rule sets
search mechanisms.
(combinational
• Scalable to large, complex,
4. Performance explosion).
dynamic environments.
• Limited scalability.
• Can integrate fast ML/AI
• Works well only in
algorithms for improved
narrow domains.
performance.
• Static knowledge;
• Adaptive and self-improving.
requires manual
• Incorporates machine learning,
updating by human
data mining, and neural
experts.
networks for automatic
5. Adaptability • No learning
knowledge refinement.
capability.
• Easily updated, flexible, and
• Difficult to maintain
maintains long-term
when domain
performance.
knowledge evolves.
8 (a) Explain the RNN in detail. 4M

Sol: A recurrent neural network (RNN) is a deep learning model that is trained
to process and convert sequential data input into a specific sequential data
output. Sequential data is data such as words, sentences, or time-series data
where sequential components interrelate based on complex semantics and
syntax rules. An RNN is a software system that consists of many
interconnected components mimicking how humans perform sequential data
conversions, such as translating text from one language to another. RNNs are
largely being replaced by transformer-based artificial intelligence (AI) and
large language models (LLM), which are much more efficient in sequential
data processing.

The following image shows a diagram of an RNN.

RNNs are made of neurons: data-processing nodes that work together to


perform complex tasks. The neurons are organized as input, output, and
hidden layers. The input layer receives the information to process, and the
output layer provides the result. Data processing, analysis, and prediction take
place in the hidden layer.

Hidden layer
RNNs work by passing the sequential data that they receive to the hidden
layers one step at a time. However, they also have a self-looping
or recurrent workflow: the hidden layer can remember and use previous
inputs for future predictions in a short-term memory component. It uses the
current input and the stored memory to predict the next sequence.
For example, consider the sequence: Apple is red. You want the RNN to
predict red when it receives the input sequence Apple is. When the hidden
layer processes the word Apple, it stores a copy in its memory. Next, when it
sees the word is, it recalls Apple from its memory and understands the full
sequence: Apple is for context. It can then predict red for improved accuracy.
This makes RNNs useful in speech recognition, machine translation, and other
language modeling tasks.

Training
Machine learning (ML) engineers train deep neural networks like RNNs by
feeding the model with training data and refining its performance. In ML, the
neuron's weights are signals to determine how influential the information
learned during training is when predicting the output. Each layer in an RNN
shares the same weight.

ML engineers adjust weights to improve prediction accuracy. They use a


technique called backpropagation through time (BPTT) to calculate model
error and adjust its weight accordingly. BPTT rolls back the output to the
previous time step and recalculates the error rate. This way, it can identify
which hidden state in the sequence is causing a significant error and readjust
the weight to reduce the error margin.

RNNs are often characterized by one-to-one architecture: one input sequence


is associated with one output. However, you can flexibly adjust them into
various configurations for specific purposes. The following are several
common RNN types.

One-to-many
This RNN type channels one input to several outputs. It enables linguistic
applications like image captioning by generating a sentence from a single
keyword.

Many-to-many
The model uses multiple inputs to predict multiple outputs. For example, you
can create a language translator with an RNN, which analyzes a sentence and
correctly structures the words in a different language.

Many-to-one
Several inputs are mapped to an output. This is helpful in applications like
sentiment analysis, where the model predicts customers’ sentiments
like positive, negative, and neutral from input testimonials.

RNNs are one of several different neural network architectures.

Recurrent neural network vs. feed-forward neural network


Like RNNs, feed-forward neural networks are artificial neural networks that
pass information from one end to the other end of the architecture. A feed-
forward neural network can perform simple classification, regression, or
recognition tasks, but it can’t remember the previous input that it has
processed. For example, it forgets Apple by the time its neuron processes the
word is. The RNN overcomes this memory limitation by including a hidden
memory state in the neuron.
Recurrent neural network vs. convolutional neural networks
Convolutional neural networks are artificial neural networks that are designed
to process spatial data. You can use convolutional neural networks to extract
spatial information from videos and images by passing them through a series
of convolutional and pooling layers in the neural network. RNNs are designed
to capture long-term dependencies in sequential data
What are some variants of recurrent neural network architecture?
The RNN architecture laid the foundation for ML models to have language
processing capabilities. Several variants have emerged that share its memory
retention principle and improve on its original functionality. The following
are some examples.
Bidirectional recurrent neural networks
A bidirectional recurrent neural network (BRNN) processes data sequences
with forward and backward layers of hidden nodes. The forward layer works
similarly to the RNN, which stores the previous input in the hidden state and
uses it to predict the subsequent output. Meanwhile, the backward layer works
in the opposite direction by taking both the current input and the future hidden
state to update the present hidden state. Combining both layers enables the
BRNN to improve prediction accuracy by considering past and future
contexts.

Long short-term memory


Long short-term memory (LSTM) is an RNN variant that enables the model
to expand its memory capacity to accommodate a longer timeline. An RNN
can only remember the immediate past input. It can’t use inputs from several
previous sequences to improve its prediction.
Consider the following sentences: Tom is a cat. Tom’s favorite food is fish.
When you’re using an RNN, the model can’t remember that Tom is a cat. It
might generate various foods when it predicts the last word. LSTM networks
add a special memory block called cells in the hidden layer. Each cell is
controlled by an input gate, output gate, and forget gate, which enables the
layer to remember helpful information. For example, the cell remembers the
words Tom and cat, enabling the model to predict the word fish.

Gated recurrent units


A gated recurrent unit (GRU) is an RNN that enables selective memory
retention. The model adds an update and forgets the gate to its hidden layer,
which can store or remove information in the memory.
What are the limitations of recurrent neural networks?
Since the RNN’s introduction, ML engineers have made significant progress
in natural language processing (NLP) applications with RNNs and their
variants. However, the RNN model family has several limitations.

Exploding gradient
An RNN can wrongly predict the output in the initial training. You need
several iterations to adjust the model’s parameters to reduce the error rate.
You can describe the sensitivity of the error rate corresponding to the model’s
parameter as a gradient. You can imagine a gradient as a slope that you take
to descend from a hill. A steeper gradient enables the model to learn faster,
and a shallow gradient decreases the learning rate.
Exploding gradient happens when the gradient increases exponentially until
the RNN becomes unstable. When gradients become infinitely large, the RNN
behaves erratically, resulting in performance issues such as overfitting.
Overfitting is a phenomenon where the model can predict accurately with
training data but can’t do the same with real-world data.

Vanishing gradient
The vanishing gradient problem is a condition where the model’s gradient
approaches zero in training. When the gradient vanishes, the RNN fails to
learn effectively from the training data, resulting in underfitting. An underfit
model can’t perform well in real-life applications because its weights weren’t
adjusted appropriately. RNNs are at risk of vanishing and exploding gradient
issues when they process long data sequences.

Slow training time


An RNN processes data sequentially, which limits its ability to process a large
number of texts efficiently. For example, an RNN model can analyze a
buyer’s sentiment from a couple of sentences. However, it requires massive
computing power, memory space, and time to summarize a page of an essay.
How do transformers overcome the limitations of recurrent neural networks?
Transformers are deep learning models that use self-attention mechanisms in
an encoder-decoder feed-forward neural network. They can process
sequential data the same way that RNNs do.

Self-attention
Transformers don’t use hidden states to capture the interdependencies of data
sequences. Instead, they use a self-attention head to process data sequences in
parallel. This enables transformers to train and process longer sequences in
less time than an RNN does. With the self-attention mechanism, transformers
overcome the memory limitations and sequence interdependencies that RNNs
face. Transformers can process data sequences in parallel and use positional
encoding to remember how each input relates to others.

Parallelism
Transformers solve the gradient issues that RNNs face by enabling parallelism
during training. By processing all input sequences simultaneously, a
transformer isn’t subjected to backpropagation restrictions because gradients
can flow freely to all weights. They are also optimized for parallel computing,
which graphic processing units (GPUs) offer for generative AI developments.
Parallelism enables transformers to scale massively and handle complex NLP
tasks by building larger models.

(b) Calculate the total number of parameters in the RNN.

Sol: From the diagram we can see: 6M


• Input layer: 5 neurons
• 1st hidden layer: 5 neurons
• 2nd hidden (recurrent) layer: 3 neurons
• Output layer: 1 neuron

1. Feed-forward weights
1. Input → Hidden-1
5 (inputs) × 5 (hidden-1) = 25

2. Hidden-1 → Hidden-2
5 × 3 = 15

3. Hidden-2 → Output
3×1=3

Total feed-forward weights:


25 + 15 + 3 = 43

2. Recurrent weights (in 2nd hidden layer)


The “Recurrence” loop indicates a recurrent hidden layer.
• If we assume a fully recurrent layer (each of the 3 hidden-2 neurons
connects to all 3, including itself):
3 × 3 = 9 recurrent weights

Total weights (feedforward + recurrent):


43 + 9 = 52

3. Bias terms
Bias for every neuron except input layer:
• Hidden-1: 5
• Hidden-2: 3
• Output: 1
Total biases:
5+3+1= 9

Total number of trainable parameters


= weights + biases = 52 + 9 = 61

Section C
9 16M

Sol: Network structure (fully connected):


• Input layer: 5 features
• Hidden layer 1: 4 neurons (with bias)
• Hidden layer 2: 3 neurons (with bias)
• Output layer: 1 neuron (with bias)

1. Weights
1. Input → Hidden 1
5 × 4 = 20 weights

2. Hidden 1 → Hidden 2
4 × 3 = 12 weights
3. Hidden 2 → Output
3 × 1 = 3 weights

Total weights
20 + 12 + 3 = 35

2. Biases
Bias in every non-input layer:
• Hidden 1: 4 biases
• Hidden 2: 3 biases
• Output: 1 bias
Total biases
4+3+1= 8

Total learnable parameters


Total parameters = weights + biases = 35 + 8 = 43

For LeafYield, the goal is to predict the crop yield in kilograms, which is
a continuous numeric value (a regression problem).
Therefore, the most appropriate loss function is:
✓ Mean Squared Error (MSE)

Ravi Shankar
AIDT, Amity University

You might also like