Assignment 01
Assignment 01
Introduction:
Deep learning is a subset of machine learning that mimics the structure and function of the
human brain through artificial neural networks. These networks are capable of learning and
adapting by adjusting internal parameters through optimization techniques. This assignment
explores fundamental deep learning concepts, including neuron computation, activation
functions, and neural network layers, implemented using Python and NumPy.
Neural networks are made up of multiple neurons organized into layers. Using NumPy, we
efficiently compute the output of multiple neurons. The dot product operation allows for
vectorized computation, optimizing neural network performance.
import numpy as np
Explanation: This code processes multiple inputs across three neurons simultaneously using
matrix multiplication. The biases adjust the final values, and NumPy’s dot product simplifies the
calculations. Using this approach, neural networks can handle large datasets efficiently, allowing
complex operations such as image recognition and text classification.
A single neuron processes inputs by applying corresponding weights and adding a bias. This is
the basic building block of a deep learning network, where multiple neurons form layers.
Deep learning networks often involve multiple layers of neurons, where each layer refines the
output of the previous layer. Below, we implement a two-layer network.
print(layer2_outputs)
Explanation: This network consists of an initial layer that processes inputs, followed by another
layer that refines and transforms the intermediate output further. This is the fundamental
principle behind deep networks, allowing them to learn hierarchical representations of data.
Activation functions introduce non-linearity, allowing neural networks to learn complex patterns.
Below, we implement the ReLU and Softmax activation functions.
class Activation_ReLU:
def forward(self, inputs):
self.output = np.maximum(0, inputs)
class Activation_Softmax:
def forward(self, inputs):
exp_values = np.exp(inputs - np.max(inputs, axis=1, keepdims=True))
self.output = exp_values / np.sum(exp_values, axis=1, keepdims=True)
Explanation: ReLU (Rectified Linear Unit) replaces negative values with zero to enhance
learning stability, while Softmax normalizes output values into probabilities for classification
tasks.
Loss functions quantify how well the model's predictions align with actual values. The
categorical cross-entropy loss function is widely used in classification problems.
import math
Explanation: Cross-entropy loss penalizes incorrect predictions more significantly when the
model is confident but wrong. It ensures that the neural network adjusts its parameters
effectively.
Batch processing improves efficiency by computing multiple input samples in parallel. This is
crucial for training deep networks on large datasets.
Explanation: Processing multiple inputs at once reduces computation time and improves
training performance. This approach is used in real-world applications such as autonomous
driving and voice recognition.
Conclusion:
This assignment covered essential deep learning concepts, from single neuron computations to
multi-layer networks. By implementing these techniques, we gain deeper insights into how
neural networks process data and make predictions. Understanding these foundations is crucial
for further exploration into advanced AI topics such as convolutional and recurrent neural
networks.