<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhik Dey on Medium]]></title>
        <description><![CDATA[Stories by Abhik Dey on Medium]]></description>
        <link>https://medium.com/@abhikdey06?source=rss-ea89d352b0d2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sATo6ig82aPliS3HBY_2Vw.png</url>
            <title>Stories by Abhik Dey on Medium</title>
            <link>https://medium.com/@abhikdey06?source=rss-ea89d352b0d2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 15:11:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhikdey06/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AlexNet: The Architecture That Changed AI]]></title>
            <link>https://medium.com/@abhikdey06/alexnet-the-architecture-that-changed-ai-6b69ad4d8af9?source=rss-ea89d352b0d2------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b69ad4d8af9</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[deep-neural-networks]]></category>
            <category><![CDATA[relu-activation-function]]></category>
            <dc:creator><![CDATA[Abhik Dey]]></dc:creator>
            <pubDate>Thu, 15 Aug 2024 06:54:33 GMT</pubDate>
            <atom:updated>2024-08-16T05:43:29.069Z</atom:updated>
            <content:encoded><![CDATA[<h4>Created by Alex Krizhevsky, Ilya Sutskever, and Geoffrey Hinton, AlexNet set a new standard in image classification, leveraging deep convolutional neural networks to outperform traditional methods and revolutionize the field of computer vision.</h4><p><strong><em>ImageNet Classification with Deep Convolutional Neural Networks </em></strong><em>by Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton. NIPS 2012</em><strong> </strong><em>(abbreviated as NeurIPS and formerly NIPS)</em><strong>.</strong></p><p><a href="https://proceedings.neurips.cc/paper_files/paper/2012/file/c399862d3b9d6b76c8436e924a68c45b-Paper.pdf">Link to the original research paper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*riXKjOc3ldIP5D5JqZTnnQ.png" /><figcaption>Source: Original Paper</figcaption></figure><p>The <strong>ImageNet Large Scale Visual Recognition Challenge (ILSVRC), </strong>launched in <strong>2010</strong>, was designed to advance computer vision by pushing the boundaries of image classification and object detection. Featuring millions of labeled images across thousands of categories, it provided a rigorous benchmark for evaluating image recognition models.</p><p><a href="https://www.image-net.org/challenges/LSVRC/index.php"><strong>ILSVRC</strong></a> gained fame for its role in popularizing deep learning, especially after AlexNet’s groundbreaking win in <strong>2012</strong>, which showcased the power of deep convolutional networks. Though the competition ended in <strong>2017</strong>, its influence endures. The ImageNet dataset remains a cornerstone for training and assessing new models, continuing to drive innovation in computer vision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*yEkXZqLYGqJ8VRXOtMhYVQ.jpeg" /><figcaption><strong>ImageNet</strong> Dataset Preview</figcaption></figure><p>In 2012, Alex Krizhevsky, Ilya Sutskever, and Geoffrey Hinton delivered a seismic shift in computer vision with their groundbreaking paper, <strong>“ImageNet Classification with Deep Convolutional Neural Networks”</strong>. Their work shattered the status quo, akin to a Richter-scale-breaking earthquake, by demonstrating the transformative power of deep convolutional networks.</p><p>The study showcased <strong>AlexNet</strong>, a neural network that achieved an unprecedented Top-5 error rate of <strong>15.3% </strong>— a substantial improvement over the second-place result of <strong>26.2%</strong>. This remarkable performance not only highlighted the superiority of deep learning techniques but also reignited interest in the field. The architecture introduced in this paper, now known as <em>AlexNet</em>, set a new benchmark and paved the way for future advancements in convolutional neural networks, eventually leading to models that surpassed human-level accuracy.</p><h4>AlexNet Architecture:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TFS3sdCyAiURlYec1afQpQ.png" /><figcaption><strong>AlexNet </strong>Architecture table</figcaption></figure><p><strong>AlexNet</strong> introduced several key innovations in deep convolutional neural networks, significantly advancing the field of computer vision. The architecture consists of:</p><ul><li><strong>5 Convolutional Layers</strong>: These layers apply convolutional filters to detect features from the input images.</li><li><strong>3 Max-Pooling Layers: </strong>These layers perform max-pooling operations to reduce the spatial dimensions of the feature maps.</li><li><strong>2 Normalization Layers:</strong> Local Response Normalization (LRN) layers help in normalizing the activations across the feature maps.</li><li><strong>2 Fully Connected Layers:</strong> These layers are used to learn high-level representations and perform classification.</li><li><strong>1 Softmax Layer:</strong> This layer outputs the final class probabilities.</li></ul><p>A distinctive feature of AlexNet is its use of <strong>GPUs </strong>to accelerate training, which was novel at the time. Each convolutional layer employs a convolutional filter followed by a non-linear activation function, <strong>ReLU</strong>, which introduces non-linearity and speeds up convergence.</p><p>The input size for AlexNet is often described as <strong>224x224x3</strong>, but due to padding applied during the convolution operations, the effective input size used in practice is <strong>227x227x3</strong>. This discrepancy arises because the paper’s original description did not account for the padding that was applied to maintain the spatial dimensions of the feature maps through the network. The padding ensures that the convolution operations do not excessively reduce the spatial size of the images, thus leading to the effective input size of <strong>227x227x3</strong>. The paper’s error in specifying <strong>224x224x3</strong> can be attributed to a misalignment in detailing the network’s exact implementation details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*S3wLKU1Zmmq1mZLpSNFmGQ.png" /><figcaption>Source: <a href="https://neurohive.io/en/popular-networks/alexnet-imagenet-classification-with-deep-convolutional-neural-networks/">Neurohive</a></figcaption></figure><h4>Key Innovations:</h4><ul><li>Utilizes ‘<strong>ReLU’</strong> as the activation function instead of traditional functions like ‘<strong>tanh’</strong>.</li><li>Incorporates ‘<strong>dropout’</strong> regularization to reduce overfitting and improve generalization.</li><li>For the first time in history leverages <strong>GPUs</strong> to accelerate training and enable the development of deeper networks.</li><li>Data Augmentation is been carried out like flipping, jittering, cropping, colour normalization, etc.</li><li>Uses overlapping max-pooling to retain more spatial information and capture finer image details.</li><li>Applies <strong>LRN</strong> to normalize activations across feature maps and enhance feature contrast</li><li><strong>SGD Momentum</strong> is used as a learning algorithm.</li></ul><h4>Impact of GPUs:</h4><p>To address the memory limitations of a single <strong>GTX 580 GPU (3 GB)</strong>, AlexNet was split across two GPUs, each managing half of the neurons (feature maps). This approach utilized cross-GPU parallelization, allowing direct memory access between GPUs without relying on the host machine’s memory.</p><p>In this setup, kernels in certain layers communicated only with those on the same GPU, optimizing the balance between data exchange and computation. This strategy, akin to a “columnar” CNN but with interdependent columns, led to a 1.7% reduction in top-1 error rate and a 1.2% reduction in top-5 error rate compared to using a single GPU with fewer kernels. The two-GPU configuration also sped up training, showcasing the benefits of parallelization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*g6kbvJJHq1gXVjdI4JzjmQ.png" /><figcaption>Source: Original Paper</figcaption></figure><h4>ReLU: Non-Linearity</h4><p>In the context of deep learning, <strong>Rectified Linear Units (ReLUs) </strong>are preferred over traditional activation functions like <strong>tanh</strong> due to their superior performance in training deep networks. ReLUs, defined as ( <strong>f(x) = max(0, x)</strong> ), offer a non-saturating nonlinearity that helps in addressing several issues associated with saturating activation functions.</p><p>Unlike <strong>tanh</strong> or <strong>sigmoid</strong> functions, which can cause gradients to vanish when inputs are in saturated regions, ReLUs do not suffer from this problem. This characteristic leads to more effective gradient flow during backpropagation, enabling faster convergence and reduced training times. In practice, networks using ReLUs often reach their training goals significantly quicker than those using tanh, as ReLUs facilitate faster learning by avoiding the saturation issues inherent in tanh.</p><p>Moreover, ReLUs improve computational efficiency, making it feasible to experiment with larger and deeper networks. The paper highlights that networks using ReLUs train several times faster than those with tanh units, as evidenced by experiments on the <strong>CIFAR-10</strong> dataset. Specifically, AlexNet with ReLUs (<em>solid curve</em>) achieved a training error rate of <strong>25%</strong> much quicker than a network using tanh (<em>dotted curve</em>), demonstrating a six-fold improvement in training speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*UPCXhyqHOnLHr2AJH6Oj2w.png" /><figcaption>How <strong>ReLU </strong>helps to reduce training error rate</figcaption></figure><h4>Local Response Normalization (LRN):</h4><p>In the AlexNet architecture, <strong>Local Response Normalization (LRN)</strong> plays a significant role in improving generalization and performance. Unlike saturating nonlinearities, <strong>ReLUs</strong> (Rectified Linear Units) do not require input normalization to prevent saturation. However, LRN is introduced as an additional mechanism to enhance the model’s generalization capability.</p><p>LRN works by implementing a form of lateral inhibition, inspired by biological neurons. This process normalizes the activity of a neuron across adjacent kernel maps at the same spatial location, creating a competition among neurons for high activations. Mathematically, if <em>\( a_{i, x, y} \)</em>​ represents the activation of a neuron after applying the ReLU function, the response-normalized activity <em>\( b_{i, x, y} \)</em>​ is computed as:</p><blockquote>\[<br>b_{i, x, y} = \frac{a_{i, x, y}}{\left( k + \frac{\alpha}{n} \sum_{j=\max(0,i-\frac{n}{2})}^{\min(N-1,i+\frac{n}{2})} (a_{j, x, y})² \right)^\beta}<br>\]</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*T96_WvF6FMrKTErBme_1xA.png" /><figcaption>LRN equation | Source: Original Paper</figcaption></figure><p>where the sum runs over <strong>n</strong> adjacent kernel maps, and <strong>N </strong>is the total number of kernels in the layer. The hyperparameters <strong>k </strong>, <strong>n </strong>, <strong>alpha </strong>, and <strong>beta </strong>are tuned using a validation set, with AlexNet using <strong>k = 2 </strong>, <strong>n = 5 </strong>, <strong>alpha = 10^{-4}</strong> \), and <strong>beta = 0.75</strong> .</p><p>LRN is applied after the ReLU nonlinearity in specific layers of the network. This normalization scheme is similar to local contrast normalization but focuses on “brightness normalization” as it doesn’t subtract the mean activity. By normalizing the responses, LRN helps reduce top-1 and top-5 error rates by 1.4% and 1.2%, respectively. Additionally, its effectiveness was validated on the CIFAR-10 dataset, where a four-layer CNN achieved a 2% reduction in test error rate when LRN was applied.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*pPfrEjWEgxcR0YiBn1TtUQ.jpeg" /><figcaption>How <strong>LRN </strong>works!</figcaption></figure><h4>Dropout: Enhancing Generalizatio</h4><p><strong>Dropout</strong> is a key technique used in AlexNet to combat overfitting and improve the generalization of the model. During training, each neuron in the network is randomly “dropped out” with a probability of 0.5, meaning it is temporarily removed from the network. This prevents the neuron from contributing to both forward and backward propagation. As a result, every input effectively passes through a different neural network configuration, all of which share the same weights.</p><p>This randomness forces the network to learn more robust features that do not rely on specific neurons, reducing complex co-adaptations. At test time, all neurons are used, but their outputs are scaled by 0.5 to approximate the effect of dropout during training. This approach allows AlexNet to generalize better to unseen data, significantly reducing overfitting. Without dropout, the network exhibited substantial overfitting, but with dropout, although training takes longer, the overall performance is vastly improved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*qM6ZRfezI6mVLz7B9X0LvA.gif" /><figcaption><strong>Dropout</strong> Visualization</figcaption></figure><h4>Stochastic Gradient Descent:</h4><p>In training AlexNet, <strong>Stochastic Gradient Descent (SGD)</strong> played a crucial role in optimizing the model’s performance. The authors used a <em>batch size</em> of <strong>128</strong> examples, a <em>momentum</em> of <strong>0.9</strong>, and a <em>weight decay</em> of <strong>0.0005</strong>. Interestingly, this small weight decay not only acted as a regularizer but also reduced the model’s training error, proving essential for effective learning.</p><p>The update rule for the model’s weights incorporated momentum, which helped smooth the optimization path and accelerated convergence by reducing oscillations. Weights were initialized using a zero-mean Gaussian distribution with a small <em>standard</em> <em>deviation</em> of <strong>0.01</strong>, while biases in certain layers were set to 1 to ensure positive inputs for the <em>ReLU</em> activation function, accelerating early learning.</p><p>The learning rate was uniformly applied across all layers, starting at 0.01, and was manually decreased by a factor of 10 whenever the validation error plateaued. This adaptive learning rate strategy was key to fine-tuning the model.</p><blockquote>Over approximately <strong>90</strong> <em>epochs</em>, the network was trained on 1.2 million images, a process that spanned <strong>five to six days</strong> on two NVIDIA GTX 580 GPUs. This meticulous approach to SGD allowed AlexNet to effectively navigate the large, complex search space of deep learning, contributing to its groundbreaking success.</blockquote><h4>Results: AlexNet’s Groundbreaking Performance</h4><p>AlexNet made history with its unprecedented performance in the 2012 ImageNet Large Scale Visual Recognition Challenge (ILSVRC). This deep convolutional neural network achieved a remarkable <strong>Top-5 error rate of just 15.3%</strong>, leaving its closest competitor far behind at 26.2%. This 10.9% margin represented a seismic shift in computer vision, showcasing the power of deep learning and setting a new standard for image classification tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*MOBZxi1GBlrgfGsIcCeiTw.png" /><figcaption>Source: Original Paper</figcaption></figure><p>The model’s success wasn’t just in its accuracy — it also demonstrated the effectiveness of using GPUs for training deep networks, as well as innovative techniques like ReLU activation functions, Dropout, and Data Augmentation. These innovations collectively enabled AlexNet to handle vast amounts of data and learn complex features, which traditional methods struggled to achieve.</p><p>AlexNet’s performance was not just a victory for its creators but a clear signal that deep learning had the potential to revolutionize the field of artificial intelligence. This breakthrough paved the way for the development of even more sophisticated architectures, cementing deep learning’s place at the forefront of machine learning research.</p><h3>AlexNet Implentation with TensorFlow (Demo Code):</h3><p>For the implementation process, we will be using a portion of the Caltech-256 dataset. This dataset will be passed through our AlexNet model to evaluate its performance and demonstrate the architecture’s effectiveness.</p><h4>Import Libraries:</h4><p>Here’s the initial setup where we import essential libraries for building, training, and visualizing the AlexNet model. These include TensorFlow for model construction and Matplotlib for visualizing results.</p><pre># Import Libraries<br><br>import os<br>import numpy as np<br>import tensorflow as tf<br>import matplotlib.pyplot as plt<br>import time<br><br>from tensorflow.keras import layers, Model, Input<br>from tensorflow.keras.preprocessing import image<br>from tensorflow.keras.preprocessing.image import ImageDataGenerator<br>from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau, ModelCheckpo = 64 # as per paper said (128)</pre><h4>Load and Pre-process the Dataset (Caltech-256):</h4><p>we load the Caltech-256 dataset and prepare it for training by resizing and normalizing the images. We use TensorFlow’s ImageDataGenerator to apply data augmentation techniques, which helps improve the model&#39;s robustness and generalization. This pre-processing ensures that the data is in optimal condition for training the AlexNet model.</p><pre>batch_size = 64 # as per paper said (128)<br><br># Define data augmentation<br>train_datagen = ImageDataGenerator(<br>    rescale=1./255,<br>    shear_range=0.2,<br>    zoom_range=0.2,<br>    horizontal_flip=True,<br>    validation_split=0.15<br>)<br><br>val_datagen = ImageDataGenerator(<br>    rescale=1./255,<br>    validation_split=0.15<br>)<br><br># Get the current working directory<br>current_directory = os.getcwd()<br><br># Load and augment the dataset<br>dataset_dir = os.path.join(current_directory, &quot;Caltech_256/256_ObjectCategories&quot;)<br><br><br>train_generator = train_datagen.flow_from_directory(<br>    dataset_dir,<br>    target_size=(227, 227),<br>    batch_size=batch_size,<br>    class_mode=&#39;sparse&#39;,<br>    subset=&#39;training&#39;<br>)<br><br>validation_generator = val_datagen.flow_from_directory(<br>    dataset_dir,<br>    target_size=(227, 227),<br>    batch_size=batch_size,<br>    class_mode=&#39;sparse&#39;,<br>    subset=&#39;validation&#39;<br>)<br><br># Print the number of images in training and validation sets<br>print(&quot;=====&quot;)<br>print(&quot;# Dataset Summary&quot;)<br>print(&quot;-----&quot;)<br>print(f&quot;Training set: {train_generator.samples} images, {train_generator.num_classes} classes&quot;)<br>print(f&quot;Validation set: {validation_generator.samples} images, {validation_generator.num_classes} classes&quot;)<br>print(&quot;-----&quot;)<br><br># Optionally, print class names for reference<br>class_names = list(train_generator.class_indices.keys())<br>print(f&quot;Classes: {class_names}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPZpiEdWkU0B-ppWRKej4w.png" /><figcaption>Output to the total Classes</figcaption></figure><h4>View the Dataset:</h4><pre># Function to plot images<br>def plot_images_from_generator(generator, num_images=12):<br>    # Retrieve a batch of images and labels<br>    images, labels = next(generator)<br>    <br>    # Define the class names<br>    class_names = list(generator.class_indices.keys())<br>    <br>    # Plot the images<br>    plt.figure(figsize=(14, 14))<br>    for i in range(num_images):<br>        plt.subplot(4, 4, i + 1)<br>        plt.imshow(images[i])<br>        plt.title(class_names[int(labels[i])])<br>        plt.axis(&#39;off&#39;)<br>    <br>    plt.show()<br><br># Plot 12 random images from the training generator<br>plot_images_from_generator(train_generator, num_images=12)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7f231njgKBRFt7TB1dQOAg.png" /><figcaption>Preview the data (Images)</figcaption></figure><h4>Define the Model:</h4><p>we will construct the AlexNet architecture from scratch using TensorFlow. While Keras offers predefined functions for building models, we will manually define the AlexNet architecture to understand its components and configuration better. This approach allows for a deeper insight into how each layer and operation contributes to the model’s performance.</p><pre># Define the custom LocalResponseNormalization layer<br>class LocalResponseNormalization(layers.Layer):<br>    def __init__(self, depth_radius, bias, alpha, beta, name, **kwargs):<br>        super(LocalResponseNormalization, self).__init__(name=name, **kwargs)<br>        self.depth_radius = depth_radius<br>        self.bias = bias<br>        self.alpha = alpha<br>        self.beta = beta<br><br>    def call(self, inputs):<br>        return tf.nn.local_response_normalization(<br>            inputs,<br>            depth_radius=self.depth_radius,<br>            bias=self.bias,<br>            alpha=self.alpha,<br>            beta=self.beta,<br>            name=self.name<br>        )<br><br># Define the AlexNet model as a subclass of the Model class<br>class AlexNet(Model):<br>    def __init__(self, input_shape=(227, 227, 3), num_classes=1000, name=&quot;AlexNet&quot;):<br>        super(AlexNet, self).__init__(name=name)<br><br>        # [Layer1] First convolutional layer <br>        self.conv1 = layers.Conv2D(filters=96, kernel_size=(11, 11), strides=4, padding=&#39;valid&#39;, activation=&#39;relu&#39;, name=&#39;conv_layer1&#39;)<br>        self.lrn1 = LocalResponseNormalization(depth_radius=5, bias=2.0, alpha=1e-4, beta=0.75, name=&#39;local_response_norm_layer1&#39;)<br>        self.pool1 = layers.MaxPooling2D(pool_size=(3, 3), strides=(2, 2), name=&#39;max_pool_layer1&#39;)<br>        <br>        # [Layer2] Second convolutional layer<br>        self.conv2 = layers.Conv2D(filters=256, kernel_size=(5, 5), padding=&#39;same&#39;, activation=&#39;relu&#39;, name=&#39;conv_layer2&#39;)<br>        self.lrn2 = LocalResponseNormalization(depth_radius=5, bias=2.0, alpha=1e-4, beta=0.75, name=&#39;local_response_norm_layer2&#39;)<br>        self.pool2 = layers.MaxPooling2D(pool_size=(3, 3), strides=(2, 2), name=&#39;max_pool_layer2&#39;)<br>        <br>        # [Layer3] Third convolutional layer<br>        self.conv3 = layers.Conv2D(filters=384, kernel_size=(3, 3), padding=&#39;same&#39;, activation=&#39;relu&#39;, name=&#39;conv_layer3&#39;)<br>        <br>        # [Layer4] Fourth convolutional layer<br>        self.conv4 = layers.Conv2D(filters=384, kernel_size=(3, 3), padding=&#39;same&#39;, activation=&#39;relu&#39;, name=&#39;conv_layer4&#39;)<br>        <br>        # [Layer5] Fifth convolutional layer<br>        self.conv5 = layers.Conv2D(filters=256, kernel_size=(3, 3), padding=&#39;same&#39;, activation=&#39;relu&#39;, name=&#39;conv_layer5&#39;)<br>        self.pool3 = layers.MaxPooling2D(pool_size=(3, 3), strides=(2, 2), name=&#39;max_pool_layer5&#39;)<br>        <br>        # Flatten the tensor to prepare for the fully connected layers<br>        self.flatten = layers.Flatten()<br><br>        # [Layer6] First fully-connected layer with dropout<br>        self.fc1 = layers.Dense(units=4096, activation=&#39;relu&#39;, name=&#39;dense_layer6&#39;)<br>        self.dropout1 = layers.Dropout(rate=0.5, name=&#39;dropout_layer6&#39;)<br><br>        # [Layer7] Second fully-connected layer with dropout<br>        self.fc2 = layers.Dense(units=4096, activation=&#39;relu&#39;, name=&#39;dense_layer7&#39;)<br>        self.dropout2 = layers.Dropout(rate=0.5, name=&#39;dropout_layer7&#39;)<br><br>        # [Layer8] Third fully-connected layer / Output layer with softmax activation<br>        self.fc3 = layers.Dense(units=num_classes, activation=&#39;softmax&#39;, name=&#39;dense_output_layer8&#39;)<br><br>    # Define the forward pass<br>    def call(self, inputs):<br>        x = self.conv1(inputs)<br>        x = self.lrn1(x)<br>        x = self.pool1(x)<br>        <br>        x = self.conv2(x)<br>        x = self.lrn2(x)<br>        x = self.pool2(x)<br>        <br>        x = self.conv3(x)<br>        <br>        x = self.conv4(x)<br>        <br>        x = self.conv5(x)<br>        x = self.pool3(x)<br>        x = self.flatten(x)<br>        <br>        x = self.fc1(x)<br>        x = self.dropout1(x)<br>        <br>        x = self.fc2(x)<br>        x = self.dropout2(x)<br>        <br>        return self.fc3(x)<br><br>    # Build the graph for the model with a given input shape<br>    def build_graph(self, input_shape=(227, 227, 3)):<br>        input_x = Input(shape=input_shape, name=&#39;input_layer&#39;)<br>        return Model(inputs=input_x, outputs=self.call(input_x), name=self.name)<br><br># Instantiate the model<br>alexnet_model = AlexNet(input_shape=(227, 227, 3), num_classes=1000)<br><br># Build the graph for the model<br>alexnet_graph = alexnet_model.build_graph()<br><br># Print the model summary<br>alexnet_graph.summary()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*dnocAZ25rDcFE2exLCfMww.png" /><figcaption>Model Architecture</figcaption></figure><h4>Training the model with GPU:</h4><pre># Model Parameters:<br>input_shape = (227, 227, 3)<br>num_classes = len(train_generator.class_indices)<br>batch_size = 64 # as per paper said (128)<br>epochs = 45  # as per paper said (90)<br><br># Initialize the model<br>model = AlexNet(input_shape=input_shape, num_classes=num_classes)<br>        <br># Compile the model with SGD optimizer<br>sgd_optimizer = tf.keras.optimizers.SGD(<br>    learning_rate=0.01,<br>    momentum=0.9,<br>    decay=0.0005,<br>    nesterov=False<br>)<br><br># Define top-1 and top-5 accuracy metrics<br>top1_acc = tf.keras.metrics.SparseTopKCategoricalAccuracy(k=1, name=&#39;top1_accuracy&#39;)<br>top5_acc = tf.keras.metrics.SparseTopKCategoricalAccuracy(k=5, name=&#39;top5_accuracy&#39;)<br><br># Model Complining:<br>model.compile(optimizer=sgd_optimizer, loss=&#39;sparse_categorical_crossentropy&#39;, metrics=[&#39;accuracy&#39;, top1_acc, top5_acc])<br><br># # Define EarlyStopping to prevent overfitting<br># early_stopping = EarlyStopping(monitor=&#39;val_loss&#39;, patience=5, restore_best_weights=True)<br><br># Define ReduceLROnPlateau to adjust learning rate<br>lr_scheduler = ReduceLROnPlateau(<br>    monitor=&#39;val_accuracy&#39;,  # Monitor validation loss<br>    factor=0.1,          # Reduce learning rate by a factor of 10<br>    patience=5,          # Number of epochs to wait before reducing the learning rate<br>    verbose=1,            # Print messages when the learning rate is adjusted<br>    min_lr=1e-5<br>)<br><br><br># Measure training time<br>training_start_time = time.time()<br><br># Use GPU if available, else fall back to CPU<br>if tf.config.list_physical_devices(&#39;GPU&#39;):<br>    with tf.device(&#39;/GPU:0&#39;):<br>        # Train the model<br>        history = model.fit(train_generator,<br>                            validation_data=validation_generator,<br>                            epochs=epochs,<br>                            callbacks=[lr_scheduler]<br>                           )<br>else:<br>    with tf.device(&#39;/CPU:0&#39;):<br>        # Train the model<br>        history = model.fit(train_generator,<br>                            validation_data=validation_generator,<br>                            epochs=epochs,<br>                            callbacks=[lr_scheduler]<br>                           )<br><br>training_end_time = time.time()<br>training_time = (training_end_time - training_start_time) / 60<br><br># Print the model summary<br>model.build_graph()<br>print(model.summary())<br>print(f&quot;Training time: {training_time:.2f} mins&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nCq_zMGTldNghga4ZId8ug.png" /></figure><p>.</p><p>.</p><p>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aLS9ki-ZRmINfgZyCrWpNA.png" /><figcaption>Training process</figcaption></figure><h4>Plotting the Model progress:</h4><pre># Method to plot training and validation metrics<br>def plot_metrics(history):<br>    # Create subplots for accuracy and loss<br>    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 5))<br><br>    # Plot training &amp; validation accuracy<br>    ax1.plot(history.history[&#39;accuracy&#39;], label=&#39;Train Accuracy&#39;)<br>    ax1.plot(history.history[&#39;val_accuracy&#39;], label=&#39;Validation Accuracy&#39;)<br>    ax1.set_title(&#39;Model Accuracy&#39;)<br>    ax1.set_xlabel(&#39;Epoch&#39;)<br>    ax1.set_ylabel(&#39;Accuracy&#39;)<br>    ax1.legend(loc=&#39;upper left&#39;)<br>    ax1.grid(True)<br><br>    # Plot training &amp; validation loss<br>    ax2.plot(history.history[&#39;loss&#39;], label=&#39;Train Loss&#39;)<br>    ax2.plot(history.history[&#39;val_loss&#39;], label=&#39;Validation Loss&#39;)<br>    ax2.set_title(&#39;Model Loss&#39;)<br>    ax2.set_xlabel(&#39;Epoch&#39;)<br>    ax2.set_ylabel(&#39;Loss&#39;)<br>    ax2.legend(loc=&#39;upper right&#39;)<br>    ax2.grid(True)<br><br>    plt.tight_layout()<br>    plt.show()<br><br>    # Compute error rates for the final epoch<br>    final_epoch = len(history.history[&#39;accuracy&#39;]) - 1<br>    train_top1_error = (1 - history.history[&#39;top1_accuracy&#39;][final_epoch]) * 100<br>    val_top1_error = (1 - history.history[&#39;val_top1_accuracy&#39;][final_epoch]) * 100<br>    train_top5_error = (1 - history.history[&#39;top5_accuracy&#39;][final_epoch]) * 100<br>    val_top5_error = (1 - history.history[&#39;val_top5_accuracy&#39;][final_epoch]) * 100<br><br>    # Create a table to display the error rates for the final epoch in percentage<br>    fig, ax = plt.subplots(figsize=(6, 2))<br>    ax.axis(&#39;tight&#39;)<br>    ax.axis(&#39;off&#39;)<br>    table_data = [<br>        [&quot;Metric&quot;, &quot;Error Rate (%)&quot;],<br>        [&quot;Train Top-1 Error&quot;, f&quot;{train_top1_error:.2f}&quot;],<br>        [&quot;Validation Top-1 Error&quot;, f&quot;{val_top1_error:.2f}&quot;],<br>        [&quot;Train Top-5 Error&quot;, f&quot;{train_top5_error:.2f}&quot;],<br>        [&quot;Validation Top-5 Error&quot;, f&quot;{val_top5_error:.2f}&quot;]<br>    ]<br><br>    table = ax.table(cellText=table_data, cellLoc=&#39;center&#39;, loc=&#39;center&#39;)<br>    table.auto_set_font_size(False)<br>    table.set_fontsize(10)<br>    table.scale(1.2, 1.2)<br><br>    plt.show()<br><br># Plot the accuracy, loss curves, and error rate table<br>plot_metrics(history)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fUb0MS2UfxNu_GkrE6vagQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*tr55gNjBDS1iwajyhYSeUg.png" /></figure><h4>Prediction:</h4><pre># Preprocess the image to the required size and scale<br>def preprocess_image(img_path, target_size=(227, 227)):<br>    <br>    # Load and preprocess the image<br>    img = image.load_img(img_path, target_size=target_size)<br>    img_array = image.img_to_array(img)<br>    img_array = np.expand_dims(img_array, axis=0)<br>    img_array /= 255.0<br>    return img_array, img<br><br><br># Decode the predictions to get top-1 and top-5 categories with probabilities<br>def decode_predictions(preds, class_indices, top=5):<br><br>    # Map class indices to class names and sort predictions<br>    index_to_class = {v: k for k, v in class_indices.items()}<br>    top_indices = preds[0].argsort()[-top:][::-1]<br>    top_classes = [index_to_class[i] for i in top_indices]<br>    top_probs = preds[0, top_indices]<br>    return top_classes, top_probs<br><br><br># Predict and display the top-1 and top-5 categories with probabilities for the given image.<br>def predict_and_display(img_path, model, class_indices):<br><br>    # Preprocess the image<br>    img_array, img = preprocess_image(img_path)<br><br>    # Make predictions<br>    preds = model.predict(img_array)<br><br>    # Decode predictions<br>    top_classes, top_probs = decode_predictions(preds, class_indices, top=5)<br><br>    # Display the image<br>    plt.imshow(img)<br>    plt.axis(&#39;off&#39;)<br><br>    # Display top-1 prediction<br>    top_1_class = top_classes[0]<br>    top_1_prob = top_probs[0]<br>    plt.title(f&quot;{top_1_class} ({top_1_prob*100:.2f}%)&quot;, fontsize=14, color=&#39;blue&#39;)<br><br>    plt.show()<br><br>    # Display top-5 predictions<br>    print(&quot;Top-5 Predictions:&quot;)<br>    for i, (cls, prob) in enumerate(zip(top_classes, top_probs)):<br>        print(f&quot;{i + 1}. {cls} ({prob*100:.2f}%)&quot;)</pre><pre># Example usage<br>image_path = &#39;images/ak47.jpg&#39;<br>predict_and_display(image_path, model, train_generator.class_indices)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*ADE4Q5s83SqlPYau0Zbb8A.png" /></figure><pre># Example usage<br>image_path = &#39;images/giraffe.jpeg&#39;<br>predict_and_display(image_path, model, train_generator.class_indices)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*6SZlazaSJWyCKeSYhSgBSA.png" /></figure><pre># Example usage<br>image_path = &#39;images/chopsticks.jpg&#39;<br>predict_and_display(image_path, model, train_generator.class_indices)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*QQz2Y0o4ONdlaiy7gOnKXw.png" /></figure><h3>Conclusion:</h3><p>In this article, we explored the groundbreaking AlexNet architecture and its impact on the field of computer vision. From its innovative use of ReLU activations and dropout to its remarkable performance in the ILSVRC 2012, AlexNet has set a new benchmark for deep learning models. We walked through the implementation process using TensorFlow and the Caltech-256 dataset to showcase how this architecture performs in practice.</p><p>Thank you for reading! If you found this article insightful, please share it with others and feel free to reach out with any questions or comments. Stay tuned for more updates and deep dives into exciting advancements in machine learning and computer vision.</p><h4>Links and References:</h4><p>AlexNet <em>GitHub</em> Repository for code implementation with <strong>TensorFlow</strong> and <strong>PyTorch</strong> : <a href="https://github.com/sparky-abhik06/AlexNet_ILSVRC-2012">https://github.com/sparky-abhik06/AlexNet_ILSVRC-2012</a></p><p><strong>Caltech-256 </strong>Dataset: <a href="https://www.kaggle.com/datasets/sparky06ad/caltech-256">https://www.kaggle.com/datasets/sparky06ad/caltech-256</a></p><p><em>Follow Me: </em><a href="https://github.com/sparky-abhik06"><strong>GitHub</strong></a> &amp; <a href="https://medium.com/@abhikdey06"><strong>Medium</strong></a></p><ol><li>Krizhevsky, Alex &amp; Sutskever, Ilya &amp; Hinton, Geoffrey. (2012). “ImageNet Classification with Deep Convolutional Neural Networks”. Neural Information Processing Systems. 25. 10.1145/3065386.</li><li>Deng, Jia &amp; Dong, Wei &amp; Socher, Richard &amp; Li, Li-Jia &amp; Li, Kai &amp; Li, Fei Fei. (2009). “ImageNet: a Large-Scale Hierarchical Image Database”. IEEE Conference on Computer Vision and Pattern Recognition. 248–255. 10.1109/CVPR.2009.5206848</li><li>Nair, Vinod &amp; Hinton, Geoffrey. (2010). “Rectified Linear Units Improve Restricted Boltzmann Machines”. Proceedings of ICML. 27. 807–814.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b69ad4d8af9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Hadoop 3.3.6 Installation on Ubuntu 22.04]]></title>
            <link>https://medium.com/@abhikdey06/apache-hadoop-3-3-6-installation-on-ubuntu-22-04-14516bceec85?source=rss-ea89d352b0d2------2</link>
            <guid isPermaLink="false">https://medium.com/p/14516bceec85</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[hadoop]]></category>
            <category><![CDATA[big-data-analytics]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[apache]]></category>
            <dc:creator><![CDATA[Abhik Dey]]></dc:creator>
            <pubDate>Tue, 07 Nov 2023 05:42:50 GMT</pubDate>
            <atom:updated>2023-11-07T05:42:50.833Z</atom:updated>
            <content:encoded><![CDATA[<p>In the ever-expanding world of big data, managing and processing vast amounts of information efficiently has become paramount for businesses and organizations. At the forefront of this data revolution stands Hadoop, a powerful open-source framework designed to tackle the challenges of distributed data storage and processing. If you’re eager to harness the potential of Hadoop for your data projects but find the installation process daunting, fear not! This comprehensive guide will walk you through the essential steps to install Hadoop on your Ubuntu system, demystifying the process and setting you on the path to unlocking the limitless possibilities of big data analytics.</p><p>Whether you are a seasoned data professional looking to bolster your skills or someone just beginning your data journey, this guide aims to make Hadoop more accessible than ever before. By the end of this journey, you’ll be well-equipped to explore the world of distributed data processing, leverage the capabilities of Hadoop, and harness its full potential for your data-driven endeavors. So, let’s dive in and embark on an exciting journey into the realm of big data analytics.</p><h3>Step 1 : Install Java Development Kit</h3><p>The default Ubuntu repositories contain Java 8 and Java 11 both. I am using Java 8 because hive only works on this version.Use the following command to install it.</p><pre>sudo apt update &amp;&amp; sudo apt install openjdk-8-jdk</pre><h3>Step 2 : Verify the Java version :</h3><p>Once you have successfully installed it, check the current Java version:</p><pre>java -version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*LJeUwvauGlArqnA3.png" /></figure><h3>Step 3 : Install SSH :</h3><p>SSH (Secure Shell) installation is vital for Hadoop as it enables secure communication between nodes in the Hadoop cluster. This ensures data integrity, confidentiality, and allows for efficient distributed processing of data across the cluster.</p><pre>sudo apt install ssh</pre><h3>Step 4 : Create the hadoop user :</h3><p>All the Hadoop components will run as the user that you create for Apache Hadoop, and the user will also be used for logging in to Hadoop’s web interface.</p><p>Run the command to create user and set password :</p><pre>sudo adduser hadoop</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*DS3Oy4HIJXJhQRAm.png" /></figure><h3>Step 5 : Switch user :</h3><p>Switch to the newly created hadoop user:</p><pre>su - hadoop</pre><h3>Step 6 : Configure SSH :</h3><p>Now configure password-less SSH access for the newly created hadoop user, so I didn’t enter key to save file and passpharse. Generate an SSH keypair first:</p><pre>ssh-keygen -t rsa</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*oFexu0cvcLoKV4qh.png" /></figure><h3>Step 7 : Set permissions :</h3><p>Copy the generated public key to the authorized key file and set the proper permissions:</p><pre>cat ~/.ssh/id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys   <br>chmod 640 ~/.ssh/authorized_keys</pre><h3>Step 8 : SSH to the localhost</h3><pre>ssh localhost</pre><p>You will be asked to authenticate hosts by adding RSA keys to known hosts. Type yes and hit Enter to authenticate the localhost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*02KgQeiDOjTl9-8k.png" /></figure><h3>Step 9 : Switch user</h3><p>Again switch to hadoop</p><pre>su - hadoop</pre><h3>Step 10 : Install hadoop</h3><ul><li>Download hadoop 3.3.6</li></ul><pre>wget https://dlcdn.apache.org/hadoop/common/hadoop-3.3.6/hadoop-3.3.6.tar.gz</pre><ul><li>Once you’ve downloaded the file, you can unzip it to a folder.</li></ul><pre>tar -xvzf hadoop-3.3.6.tar.gz</pre><ul><li>Rename the extracted folder to remove version information. This is an optional step, but if you don’t want to rename, then adjust the remaining configuration paths.</li></ul><pre>mv hadoop-3.3.6 hadoop</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*mmI3e9ggGc1aW5ad.png" /></figure><ul><li>Next, you will need to configure Hadoop and Java Environment Variables on your system. Open the ~/.bashrc file in your favorite text editor.Here I am using nano editior , to pasting the code we use ctrl+shift+v for saving the file ctrl+x and ctrl+y ,then hit enter:</li></ul><pre>nano ~/.bashrc</pre><ul><li>Append the below lines to the file.</li></ul><pre>export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64<br>export HADOOP_HOME=/home/hadoop/hadoop<br>export HADOOP_INSTALL=$HADOOP_HOME<br>export HADOOP_MAPRED_HOME=$HADOOP_HOME<br>export HADOOP_COMMON_HOME=$HADOOP_HOME<br>export HADOOP_HDFS_HOME=$HADOOP_HOME<br>export HADOOP_YARN_HOME=$HADOOP_HOME<br>export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native<br>export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin<br>export HADOOP_OPTS=&quot;-Djava.library.path=$HADOOP_HOME/lib/native&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*_VFketzpLXqfNfaQ.png" /></figure><ul><li>Load the above configuration in the current environment.</li></ul><pre>source ~/.bashrc</pre><ul><li>You also need to configure JAVA_HOME in hadoop-env.sh file. Edit the Hadoop environment variable file in the text editor:</li></ul><pre>nano $HADOOP_HOME/etc/hadoop/hadoop-env.sh</pre><p>Search for the “export JAVA_HOME” and configure it .</p><pre>JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*KaHinSMy0TB5GvJO.png" /></figure><h3>Step 11 : Configuring Hadoop :</h3><ul><li>First, you will need to create the <strong>namenode</strong> and <strong>datanode</strong> directories inside the Hadoop user home directory. Run the following command to create both directories:</li></ul><pre>cd hadoop/</pre><pre>mkdir -p ~/hadoopdata/hdfs/{namenode,datanode}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*F4TUQ5JnSvldn9CP.png" /></figure><ul><li>Next, edit the core-site.xml file and update with your system hostname:</li></ul><pre>nano $HADOOP_HOME/etc/hadoop/core-site.xml</pre><p>Change the following name as per your system hostname:</p><pre>&lt;configuration&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;fs.defaultFS&lt;/name&gt;<br>        &lt;value&gt;hdfs://localhost:9000&lt;/value&gt;<br>    &lt;/property&gt;<br>&lt;/configuration&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*j29Hb8qvy30mrJ32.png" /></figure><p>Save and close the file.</p><ul><li>Then, edit the hdfs-site.xml file:</li></ul><pre>nano $HADOOP_HOME/etc/hadoop/hdfs-site.xml</pre><ul><li>Change the NameNode and DataNode directory paths as shown below:</li></ul><pre>&lt;configuration&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;dfs.replication&lt;/name&gt;<br>        &lt;value&gt;1&lt;/value&gt;<br>    &lt;/property&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;dfs.namenode.name.dir&lt;/name&gt;<br>        &lt;value&gt;file:///home/hadoop/hadoopdata/hdfs/namenode&lt;/value&gt;<br>    &lt;/property&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;dfs.datanode.data.dir&lt;/name&gt;<br>        &lt;value&gt;file:///home/hadoop/hadoopdata/hdfs/datanode&lt;/value&gt;<br>    &lt;/property&gt;<br> &lt;/configuration&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*VST1VNPFlc4yWb-T.png" /></figure><ul><li>Then, edit the mapred-site.xml file:</li></ul><pre>nano $HADOOP_HOME/etc/hadoop/mapred-site.xml</pre><ul><li>Make the following changes:</li></ul><pre>&lt;configuration&gt;<br>   &lt;property&gt;<br>      &lt;name&gt;yarn.app.mapreduce.am.env&lt;/name&gt;<br>      &lt;value&gt;HADOOP_MAPRED_HOME=$HADOOP_HOME/home/hadoop/hadoop/bin/hadoop&lt;/value&gt;<br>   &lt;/property&gt;<br>   &lt;property&gt;<br>      &lt;name&gt;mapreduce.map.env&lt;/name&gt;<br>      &lt;value&gt;HADOOP_MAPRED_HOME=$HADOOP_HOME/home/hadoop/hadoop/bin/hadoop&lt;/value&gt;<br>   &lt;/property&gt;<br>   &lt;property&gt;<br>      &lt;name&gt;mapreduce.reduce.env&lt;/name&gt;<br>      &lt;value&gt;HADOOP_MAPRED_HOME=$HADOOP_HOME/home/hadoop/hadoop/bin/hadoop&lt;/value&gt;<br>   &lt;/property&gt;<br>&lt;/configuration&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*sNnCKHS5oYlL4yUr.png" /></figure><ul><li>Then, edit the yarn-site.xml file:</li></ul><pre>nano $HADOOP_HOME/etc/hadoop/yarn-site.xml</pre><ul><li>Make the following changes:</li></ul><pre>&lt;configuration&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;yarn.nodemanager.aux-services&lt;/name&gt;<br>        &lt;value&gt;mapreduce_shuffle&lt;/value&gt;<br>    &lt;/property&gt;<br>&lt;/configuration&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*fsoNMhzcz3zp0pt7.png" /></figure><p>Save the file and close it .</p><h3>Step 12 : Start Hadoop cluster:</h3><ul><li>Before starting the Hadoop cluster. You will need to format the <strong>Namenode</strong> as a hadoop user.</li><li>Run the following command to format the Hadoop <strong>Namenode</strong>:</li></ul><pre>hdfs namenode -format</pre><ul><li>Once the <strong>namenode</strong> directory is successfully formatted with hdfs file system, you will see the message “Storage directory /home/hadoop/hadoopdata/hdfs/namenode has been successfully formatted”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*uxDDJYZbrPvz3hSu.png" /></figure><ul><li>Then start the Hadoop cluster with the following command.</li></ul><pre>start-all.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*_xwCy2Pbdgvs25kj.png" /></figure><ul><li>You can now check the status of all Hadoop services using the jps command:</li></ul><pre>jps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*Rl2_ZShG8tdtsu4-.png" /></figure><h3>Step 13 : Access Hadoop Namenode and Resource Manager :</h3><ul><li>First we need to know our ip address,In Ubuntu we need to install net-tools to run ipconfig command, If you installing net-tools for the first time switch to default user :</li></ul><pre>sudo apt install net-tools</pre><ul><li>Then run <strong>ifconfig</strong> command to know our ip address:</li></ul><pre>ifconfig</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*CUQcumQGdpeMLta5.png" /></figure><p>Here my ip address is 192.168.1.6.</p><ul><li>To access the <strong>Namenode</strong>, open your web browser and visit the URL <a href="http://your-server-ip:9870./">http://your-server-ip:9870.</a> You should see the following screen:</li></ul><p><a href="http://hadoop.tecadmin.net:9870/"><strong>http://192.168.1.6:9870</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*pdSua4ccj8bu9jrE.png" /></figure><ul><li>To access Resource Manage, open your web browser and visit the URL <a href="http://your-server-ip:8088./">http://your-server-ip:8088.</a> You should see the following screen:</li></ul><p><a href="http://hadoop.tecadmin.net:8088/">http://192.168.1.6:8088</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*Rp_Od_bJl-VAcH5m.png" /></figure><h3>Step 13 :Verify the Hadoop Cluster :</h3><p>At this point, the Hadoop cluster is installed and configured. Next, we will create some directories in the HDFS filesystem to test the Hadoop.</p><ul><li>Let’s create some directories in the HDFS filesystem using the following command:</li></ul><pre>hdfs dfs -mkdir /test1<br>hdfs dfs -mkdir /logs</pre><ul><li>Next, run the following command to list the above directory:</li></ul><pre>hdfs dfs -ls /</pre><p>You should get the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*_fpZ9zj3OeGpWXCO.png" /></figure><ul><li>Also, put some files to <strong>hadoop</strong> file system. For the example, putting log files from host machine to <strong>hadoop</strong> file system.</li></ul><pre>hdfs dfs -put /var/log/* /logs/</pre><p>You can also verify the above files and directory in the Hadoop web interface.</p><p>Go to the web interface, click on the Utilities =&gt; Browse the file system. You should see your directories which you have created earlier in the following screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*eMK5B213oBLjpr2o.png" /></figure><h3>Step 14 : To stop hadoop services :</h3><p>To stop the Hadoop service, run the following command as a hadoop user:</p><pre>stop-all.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*BgR2e2IKV9DwD9rR.png" /></figure><p>This tutorial explained to you step-by-step tutorial to install and configure Hadoop on Ubuntu 22.04 Linux system.</p><h3>Conclusion:</h3><p>In summary, you&#39;ve now equipped yourself with the knowledge and skills to install Hadoop on your Ubuntu system, marking the first step towards unlocking the immense potential of big data analytics. By conquering the installation process, you&#39;ve paved the way for exploring the vast world of distributed data processing and analysis.</p><p>With Hadoop at your disposal, you have a formidable tool to tackle the challenges of managing and processing massive datasets. Whether you&#39;re a seasoned data professional seeking to expand your expertise or a newcomer to the world of data, this guide has made Hadoop more accessible than ever before.</p><p>So, as you embark on your journey into the realm of big data analytics, remember that this is just the beginning. There&#39;s a wealth of possibilities waiting for you to discover and harness. Happy exploring, and may your data-driven endeavors lead to valuable insights and groundbreaking discoveries!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14516bceec85" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>