<?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 Navdeep Sidana on Medium]]></title>
        <description><![CDATA[Stories by Navdeep Sidana on Medium]]></description>
        <link>https://medium.com/@nsidana123?source=rss-c2a1c1bea4dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*a0zj6YpkN1fSeUYGc30RYg.png</url>
            <title>Stories by Navdeep Sidana on Medium</title>
            <link>https://medium.com/@nsidana123?source=rss-c2a1c1bea4dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 06:30:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nsidana123/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[Real-Time Pose Tracking with MediaPipe: A Comprehensive Guide for Fitness Applications: Series 2]]></title>
            <link>https://medium.com/@nsidana123/real-time-pose-tracking-with-mediapipe-a-comprehensive-guide-for-fitness-applications-series-2-731b1b0b8f4d?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/731b1b0b8f4d</guid>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[vision]]></category>
            <category><![CDATA[mediapipe]]></category>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 18:52:08 GMT</pubDate>
            <atom:updated>2025-04-14T18:52:08.606Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*Lz_r6TtWbPaXj2ZJwnscRQ.jpeg" /></figure><h3>Real-Time Pose Tracking with MediaPipe: A Comprehensive Guide for Fitness Applications</h3><p>Human pose estimation has evolved from complex research to accessible technology thanks to libraries like MediaPipe. This advanced computer vision technique identifies and tracks key points on the human body, enabling applications from fitness coaching to rehabilitation monitoring. The following article is the first in a two-part series exploring real-time pose tracking implementation and its practical applications in fitness technology.</p><h3>Creating a Basic Real-Time Pose Tracker with MediaPipe and Python</h3><h3>Setting Up Your Environment</h3><ul><li><strong>Required Libraries</strong></li><li>OpenCV for video capture and image processing</li><li>MediaPipe for pose detection capabilities</li><li>NumPy for numerical operations and data handling</li><li><strong>Development Prerequisites</strong></li><li>Python 3.7 or higher installed on your system</li><li>Basic understanding of computer vision concepts</li><li>Familiarity with Python programming language</li></ul><h3>Implementation Pipeline</h3><ul><li><strong>Initial Setup and Imports</strong></li><li>Import necessary libraries (OpenCV, MediaPipe, NumPy)</li><li>Initialize MediaPipe drawing utilities and pose module</li><li>These components form the foundation of our pose detection system</li></ul><pre>import cv2<br>import mediapipe as mp<br>import numpy as np</pre><pre># MediaPipe Pose Estimation initialization<br>mp_drawing = mp.solutions.drawing_utils<br>mp_pose = mp.solutions.pose</pre><ul><li><strong>Webcam Initialization</strong></li><li>Configure video capture from default camera</li><li>This creates a pipeline for receiving continuous frames for processing</li></ul><pre>cap = cv2.VideoCapture(0)</pre><ul><li><strong>Pose Detection Configuration</strong></li><li>Set confidence thresholds for detection and tracking</li><li>These parameters balance accuracy with performance</li></ul><pre>with mp_pose.Pose(min_detection_confidence=0.3, min_tracking_confidence=0.1) as pose:</pre><ul><li><strong>Processing Loop Implementation</strong></li><li>Capture frames from webcam feed</li><li>Convert color space for MediaPipe compatibility (BGR to RGB)</li><li>Process image through pose detection model</li><li>Convert back to BGR for display purposes</li><li>This loop manages the continuous stream of video frames</li></ul><pre>while cap.isOpened():<br>    ret, Image = cap.read()<br>    Image = cv2.cvtColor(Image, cv2.COLOR_BGR2RGB)<br>    Image.flags.writeable = False<br>    results = pose.process(Image)<br>    Image.flags.writeable = True<br>    Image = cv2.cvtColor(Image, cv2.COLOR_RGB2BGR)</pre><ul><li><strong>Visualization and Display</strong></li><li>Draw detected pose landmarks and connections</li><li>Display the processed image with annotations</li><li>The visual feedback confirms proper detection and tracking</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*gFqQE3f9o3JAK4SfPq01dg.png" /></figure><pre>mp_drawing.draw_landmarks(Image, results.pose_landmarks, mp_pose.POSE_CONNECTIONS,<br>                          mp_drawing.DrawingSpec(color=(245, 117, 66), thickness=8, circle_radius=4),<br>                          mp_drawing.DrawingSpec(color=(245, 66, 230), thickness=4, circle_radius=2))<br>cv2.imshow(&#39;Media pipe pose detection&#39;, Image)</pre><ul><li><strong>Graceful Termination</strong></li><li>Implement keyboard interrupt (q key) for controlled exit</li><li>Release resources and close windows properly</li><li>This ensures clean program termination without resource leaks</li></ul><pre>if cv2.waitKey(10) &amp; 0xFF == ord(&#39;q&#39;):<br>    break<br>cap.release()<br>cv2.destroyAllWindows()</pre><h3>Technical Insights on MediaPipe Pose</h3><ul><li><strong>Keypoint Detection System</strong></li><li>MediaPipe’s pose model identifies 30 distinct keypoints on the human body</li><li>These points include major joints, facial landmarks, and torso markers</li><li>The comprehensive keypoint system enables detailed pose analysis</li><li><strong>Real-Time Processing Capability</strong></li><li>The implementation processes frames sequentially with minimal latency</li><li>Adjustable confidence thresholds allow balancing between speed and accuracy</li><li>This real-time capability is essential for interactive applications</li><li><strong>Landmark Visualization</strong></li><li>Custom drawing specifications enhance visual clarity</li><li>Different colors distinguish landmarks from connections</li><li>These visualization options improve user understanding of detected poses</li></ul><pre># Full Code<br># %pip install opencv-python<br># %pip install mediapipe<br><br>import cv2<br>import mediapipe as mp<br>import numpy as np<br><br># MEdiapipe Pose Estimation<br>mp_drawing = mp.solutions.drawing_utils<br>mp_pose = mp.solutions.pose<br><br>cap = cv2.VideoCapture(0)<br>with mp_pose.Pose(min_detection_confidence=0.3, min_tracking_confidence=0.1) as pose:<br>    while cap.isOpened():<br>        ret, Image = cap.read()<br>        Image = cv2.cvtColor(Image, cv2.COLOR_BGR2RGB)<br>        Image.flags.writeable = False<br>        results = pose.process(Image)<br>        Image.flags.writeable = True<br>        Image = cv2.cvtColor(Image, cv2.COLOR_RGB2BGR)  # Re-enable color conversion<br>        mp_drawing.draw_landmarks(Image, results.pose_landmarks, mp_pose.POSE_CONNECTIONS,<br>                                   mp_drawing.DrawingSpec(color=(245, 117, 66), thickness=8, circle_radius=4),<br>                                   mp_drawing.DrawingSpec(color=(245, 66, 230), thickness=4, circle_radius=2))<br>        cv2.imshow(&#39;Media pipe pose detection&#39;, Image)<br><br>        if cv2.waitKey(10) &amp; 0xFF == ord(&#39;q&#39;):<br>            break<br><br>cap.release()<br>cv2.destroyAllWindows()</pre><p>Thanks for reading the article this far. If you like this, Please clap 93 Times and build an app to count the number of claps and I will see you in next article doing dead lifts or Fitness Exercises, code for this is available on <a href="https://github.com/369hiper/Pose-Estimation-AI-Fitness-App.git"><strong>Github</strong></a>. Happy Learning</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=731b1b0b8f4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Simple Guide to Live Pose Estimation from Your Webcam Using MediaPipe: Series 1]]></title>
            <link>https://towardsdev.com/a-simple-guide-to-live-pose-estimation-from-your-webcam-using-mediapipe-series-1-01633b692172?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/01633b692172</guid>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mediapipe]]></category>
            <category><![CDATA[ml-engineering]]></category>
            <category><![CDATA[pose-estimation]]></category>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Sun, 13 Apr 2025 07:25:18 GMT</pubDate>
            <atom:updated>2025-04-14T10:28:24.301Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*COtgo1y3Ji6sLrzdf8MVoA.jpeg" /></figure><p>In this article, we’ll explore how to capture live pose<br>estimation using your webcam with just a few lines of Python<br>code. Let’s break down the key components behind this setup.</p><p><strong>1. Setting Up the Webcam Feed</strong><br>We start by importing the necessary libraries: OpenCV for<br>image processing and Mediapipe for pose estimation. The code<br>then initializes the webcam using `VideoCapture(0)`, which<br>captures frames continuously. Where zero denotes the deviceID. You can play around with the index ‘0’ if you face issues with webcam.</p><pre><br>cap = cv2.VideoCapture(0)<br></pre><p><strong>2. Displaying the Raw Webcam Feed</strong><br>In a loop, we capture each frame from the webcam and display<br>it in a window titled ‘Raw Webcam feed’. The code waits for<br>10 milliseconds and checks if the user pressed ‘q’ to exit.</p><pre><br>while cap.isOpened():<br> ret, Image = cap.read()<br> cv2.imshow(‘Raw Webcam feed’, Image)<br>if cv2.waitKey(10) &amp; 0xFF == ord(‘q’):<br> break<br>cap.release()<br>cv2.destroyAllWindows()<br></pre><p><strong>3. Introducing Mediapipe Pose Estimation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*bfxotduKxjY8oWVzIGgf_Q.jpeg" /></figure><p>Next, we incorporate Mediapipe’s pose estimation model into<br>the setup. We import the necessary components and initialize<br>the model with minimum confidence levels for detection and<br>tracking.</p><pre><br>with mp_pose.Pose(min_detection_confidence=0.1,<br>min_tracking_confidence=0.1) as pose:<br> while cap.isOpened():<br> ret, Image = cap.read()<br> cv2.imshow(‘Media pipe pose detection’, Image)<br>if cv2.waitKey(10) &amp; 0xFF == ord(‘q’):<br> break<br>cap.release()<br>cv2.destroyAllWindows()<br></pre><p><strong>4. The Full Picture</strong><br>Combining these elements, we have two windows side by side:<br>the raw feed and the processed pose estimation. This setup<br>allows us to see both versions simultaneously.</p><h3>Final Output:</h3><p>- A raw webcam feed.<br>- The same feed with Mediapipe’s pose estimation overlay.</p><p>5. Key Takeaways<br>- OpenCV: Handles capturing and displaying the video<br>frames.<br>- Mediapipe: Provides the pose estimation model, running<br>in real-time.<br>- Confidence Levels: Set to `0.1` for quick processing<br>but can be adjusted for accuracy.</p><h3><strong>Why This Matters:</strong></h3><p>This setup is ideal for basic applications where pose<br>estimation is needed without heavy computations. It’s easy to<br>adjust parameters like confidence levels for different use<br>cases.</p><h3>What’s Next?</h3><p>- Explore different pose detection models.<br>- Adjust the confidence thresholds for better results.<br>- Apply this to video files instead of live feeds.</p><p><strong>Final Thoughts:</strong></p><p>This simple setup offers a quick way to visualize pose<br>estimation from your webcam. Whether you’re tracking fitness<br>or creating animations, it serves as a solid foundation that<br>can be expanded with additional features.</p><p>In the next coming articles we are going to draw points from center of identification of focal points.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01633b692172" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/a-simple-guide-to-live-pose-estimation-from-your-webcam-using-mediapipe-series-1-01633b692172">A Simple Guide to Live Pose Estimation from Your Webcam Using MediaPipe: Series 1</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Convolutional Neural Networks on the CIFAR-10 Dataset]]></title>
            <link>https://medium.com/@nsidana123/using-convolutional-neural-networks-on-the-cifar-10-dataset-1a2dc394cdd0?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a2dc394cdd0</guid>
            <category><![CDATA[mls]]></category>
            <category><![CDATA[dl]]></category>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Wed, 12 Feb 2025 23:14:04 GMT</pubDate>
            <atom:updated>2025-02-12T23:14:04.511Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iV4wpfKmS09flBYGEwm0Mg.gif" /><figcaption>Credit: <a href="https://tikz.net/neural_networks/">https://tikz.net/neural_networks/</a></figcaption></figure><h4>Table of Contents</h4><ol><li>Introduction</li><li>Understanding the CIFAR-10 Dataset</li><li>Fundamentals of Convolutional Neural Networks</li><li>Setting Up the Environment</li><li>Data Preprocessing</li><li>Building the CNN Model</li><li>Training the Model</li><li>Evaluating the Model</li><li>Hyperparameter Tuning</li><li>Advanced Techniques</li><li>Conclusion</li></ol><h3>1. Introduction</h3><p>Convolutional Neural Networks (CNNs) have become a cornerstone in the field of computer vision, enabling machines to achieve remarkable accuracy in image recognition tasks. This article delves into the application of CNNs on the CIFAR-10 dataset, a widely used benchmark in the machine learning community. We will explore the entire process, from understanding the dataset to building, training, and evaluating a CNN model.</p><h3>2. Understanding the CIFAR-10 Dataset</h3><p>The CIFAR-10 dataset consists of 60,000 32x32 color images in 10 different classes, with 6,000 images per class. The dataset is divided into 50,000 training images and 10,000 test images. The classes include airplanes, automobiles, birds, cats, deer, dogs, frogs, horses, ships, and trucks</p><h4>Dataset Structure</h4><ul><li>Training Set: 50,000 images</li><li>Test Set: 10,000 images</li><li>Classes: Airplane, Automobile, Bird, Cat, Deer, Dog, Frog, Horse, Ship, Truck</li></ul><h3>3. Fundamentals of Convolutional Neural Networks</h3><p>CNNs are a type of deep learning model specifically designed for processing structured grid data, such as images. They consist of several layers, including convolutional layers, pooling layers, and fully connected layers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*wvwT9LlHcDfexIiv7fWWxA.gif" /></figure><h4>Key Components</h4><ul><li>Convolutional Layers: Apply filters to the input image to extract features.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*Grn3jXIUNQ0nDryI8KTg7w.gif" /><figcaption>Credit: <a href="https://medium.com/@adarsh97ada/convolutional-neural-networks-what-is-exactly-happening-39308005b4f1">Convolutional Neural Networks: What is exactly happening? | by Adarsh …</a></figcaption></figure><ul><li>Pooling Layers: Reduce the spatial dimensions of the feature maps.</li><li>Fully Connected Layers: Perform classification based on the extracted features.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*WvHC5bKyrHa7Wm3ca-pXtg.gif" /><figcaption>Credit: <a href="https://www.analyticsvidhya.com/blog/2021/08/a-hands-on-guide-to-build-your-first-convolutional-neural-network-model/">https://www.analyticsvidhya.com/blog/2021/08/a-hands-on-guide-to-build-your-first-convolutional-neural-network-model/</a></figcaption></figure><h3>4. Setting Up the Environment</h3><p>To get started, we need to set up our Python environment with the necessary libraries. We will use TensorFlow and Keras for building and training our CNN model.</p><pre>import tensorflow as tf<br>from tensorflow.keras import datasets, layers, models<br>import matplotlib.pyplot as plt</pre><pre># Load and preprocess the CIFAR-10 dataset<br>(train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data()<br>train_images, test_images = train_images / 255.0, test_images / 255.0</pre><h3>5. Data Preprocessing</h3><p>Data preprocessing is a crucial step in any machine learning project. For the CIFAR-10 dataset, we will normalize the pixel values to be between 0 and 1.</p><pre># Normalize pixel values to be between 0 and 1<br>train_images, test_images = train_images / 255.0, test_images / 255.0</pre><h3>6. Building the CNN Model</h3><p>We will build a simple CNN model with three convolutional layers followed by max-pooling layers, and two fully connected layers.</p><pre>model = models.Sequential([<br>    layers.Conv2D(32, (3, 3), activation=&#39;relu&#39;, input_shape=(32, 32, 3)),<br>    layers.MaxPooling2D((2, 2)),<br>    layers.Conv2D(64, (3, 3), activation=&#39;relu&#39;),<br>    layers.MaxPooling2D((2, 2)),<br>    layers.Conv2D(64, (3, 3), activation=&#39;relu&#39;),<br>    layers.Flatten(),<br>    layers.Dense(64, activation=&#39;relu&#39;),<br>    layers.Dense(10)<br>])</pre><h3>7. Training the Model</h3><p>We will compile the model using the Adam optimizer and sparse categorical cross-entropy loss function, then train it on the CIFAR-10 dataset.</p><pre>model.compile(optimizer=&#39;adam&#39;,<br>              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),<br>              metrics=[&#39;accuracy&#39;])</pre><pre>history = model.fit(train_images, train_labels, epochs=10, <br>                    validation_data=(test_images, test_labels))</pre><h3>8. Evaluating the Model</h3><p>After training, we evaluate the model’s performance on the test dataset.</p><pre>test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2)<br>print(f&quot;Test accuracy: {test_acc}&quot;)</pre><h3>9. Hyperparameter Tuning</h3><p>Hyperparameter tuning involves adjusting the model’s parameters to improve performance. This can include changing the number of layers, the number of filters, the learning rate, and more.</p><h3>10. Advanced Techniques</h3><p>Advanced techniques such as data augmentation, transfer learning, and ensemble methods can further enhance the model’s performance.</p><h3>11. Conclusion</h3><p><a href="https://colab.research.google.com/drive/1D_CWIy6Jn78EM3lap7ioeh5GhicDhNrU?usp=sharing">Google Colab</a></p><p><em>Using CNNs on the CIFAR-10 dataset demonstrates the power of deep learning in image classification tasks. By following the steps outlined in this article, you can build and train your own CNN model to achieve high accuracy on image recognition tasks. Happy Neural Nets.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a2dc394cdd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enterprise-Grade Data Analysis Workflow: Optimizing Shipping Cost Visualizations in Tableau with…]]></title>
            <link>https://medium.com/@nsidana123/enterprise-grade-data-analysis-workflow-optimizing-shipping-cost-visualizations-in-tableau-with-aae6388198c0?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/aae6388198c0</guid>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[bi]]></category>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Wed, 12 Feb 2025 16:57:40 GMT</pubDate>
            <atom:updated>2025-02-12T16:58:19.087Z</atom:updated>
            <content:encoded><![CDATA[<h3>Enterprise-Grade Data Analysis Workflow: Optimizing Shipping Cost Visualizations in Tableau with Multi-Source Excel Integration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*iNSFOdt-S05_vv5CT34pFQ.png" /></figure><h4>Introduction to Multisource Analysis</h4><p>This hands on tutorial explores how to analyze shipping cost patterns across multiple Excel datasets using Tableau. We compare four data sources (MFS_Orders.xlsx, MFS_SalesProducts.xlsx, MFS_Customers.xlsx, and MFS_Data.xlsx) to identify the most robust dataset for visualization, troubleshoot data inconsistencies, and create dynamic dashboards.</p><h3>Pre-Requisites</h3><ul><li>Tableau Desktop 2023.3+ (Trial/Commercial)</li><li>Cleaned Excel datasets:</li><li><em>MFS_Orders.xlsx</em> (Primary transactional data)</li><li><em>MFS_Data.xlsx</em> (Q1 2024 updates)</li><li>Basic understanding of dimensional modeling</li></ul><blockquote><strong>Phase 1: Data Source Evaluation </strong><br><strong>Step 1: Structural Analysis </strong><br>1. MFS_Orders.xlsx <br> — Orders worksheet: 48+ columns with 4-year historical data (2020–2023) <br> — Key fields: Shipping Cost, Region, Shipping Method, Order Date <br> — Strength: High granularity for trend analysis</blockquote><blockquote>2. MFS_SalesProducts.xlsx <br> — Orders worksheet: 32 columns (limited dimensions) <br> — Products worksheet: SKU-level attributes (Category, Unit Cost) <br> — Limitation: Missing regional segmentation metrics</blockquote><blockquote>3. MFS_Orders.xlsx <br> — 2024 Q1 worksheet: Current-year transactions (Jan-Mar 2024) <br> — Critical Note: Schema variance (Territory vs Region, Ship Method vs Shipping Method)</blockquote><blockquote><strong>Step 2: Source Selection Criteria </strong><br>- Optimal Choice: MFS_Orders.xlsx + MFS_Data.xlsx (Combined) <br>- Rationale: <br> — Completeness: 4-year history + real-time Q1 updates <br> — Schema Alignment: Requires field mapping for temporal continuity</blockquote><blockquote><strong>Phase 2: Tableau Visualization Protocol </strong><br><strong>Step 1: Initial Dashboard Development </strong><br>tableau<br>1. Connect → Microsoft Excel → MFS_Orders.xlsx <br>2. Worksheet Setup: <br> — Rows: [Region] + [Shipping Method] <br> — Columns: SUM([Shipping Cost]) <br> — Marks → Color: [Shipping Method] <br>3. Rename sheet: “Shipping Cost Analysis (2020–2023)”</blockquote><blockquote>Output Validation: <br>- Verify color legend matches shipping methods <br>- Confirm regional sorting (ASC/DESC) aligns with business geography</blockquote><blockquote><strong>Step 2: Temporal Segmentation (2024 Focus) </strong><br>1. Data Source Transition: <br> — Problem: Insufficient 2024 data in primary source <br> — Solution: Hybrid sourcing with MFS_Data.xlsx <br>tableau<br>1. Data → Replace Data Source: <br> — Current: MFS_Orders.Orders <br> — Replacement: MFS_Data.’2024 Q1&#39; <br>2. Field Mapping: <br> — [Region] → [Territory] <br> — [Shipping Method] → [Ship Method]</blockquote><ol><li>Examine the <strong>Orders</strong> worksheet, scrolling as necessary to view all of the columns and all of the rows.</li><li>This worksheet contains four years’ worth of sales data. Each row is a line item of an order. Comprehensive information like this can be helpful in creating visualizations.</li><li>Close the file without saving changes.</li><li>Open <strong>MFS_SalesProducts.xlsx</strong>, and examine the <strong>Orders</strong> worksheet.</li><li>This worksheet also includes four years’ worth of sales data, with each row as a line item of an order, but it contains fewer columns than the other <strong>Orders</strong> worksheet.</li><li>Examine the <strong>Products</strong> worksheet.</li><li>This worksheet contains details about each product.</li><li>Close the file without saving changes.</li><li>Open <strong>MFS_Customers.xlsx</strong>, and examine the <strong>MFSCustomers</strong> worksheet.</li><li>This worksheet contains location information about each customer.</li><li>Close the file without saving changes.</li><li>Open <strong>MFS_Data.xlsx</strong> and examine the <strong>Orders</strong> worksheet.</li><li>This worksheet is equivalent to the <strong>Orders</strong> worksheet in the <strong>MFS_SalesProducts.xlsx</strong> file.</li><li>Examine the <strong>2024 Q1</strong> worksheet.</li><li>This worksheet contains recent orders.</li><li>Close the file without saving changes.</li><li>Now that you’ve reviewed each of the potential data sources\, which do you think is the best option for general-purpose data analysis? <a href="https://labclient.labondemand.com/Instructions/a81f311a-0846-43e1-bf91-8beaf8f9eb85">Click here for the answer.</a></li><li>Start Tableau</li><li>Start Tableau Desktop.<br> The trial version of Tableau Desktop is available for 14 days.</li><li>In the <strong>Welcome to Tableau</strong> window, select <strong>Start trial now</strong>.</li><li>In the <strong>Registration</strong> window, type the email address you are using for the class then select the <strong>Register</strong> button.<br> This may be an account that you own, or it may be one provided by your instructor.</li><li>Select <strong>Continue</strong>.</li><li>Connect to a data source, and create a horizontal bar chart showing <strong>Shipping Cost</strong> by <strong>Region</strong> and <strong>Shipping Method</strong>.</li><li>In the <strong>Connect</strong> pane, select <strong>Microsoft Excel</strong>.</li><li>If necessary, in the <strong>Open</strong> dialog box, navigate to <strong>C:\095216Data\Connecting to Data</strong>.</li><li>Select <strong>MFS_Orders.xlsx</strong>, and then select <strong>Open</strong>.</li><li>Select <strong>Sheet 1</strong> to go to the worksheet.</li><li>Name the sheet Shipping Cost by Region and Method</li><li>Drag <strong>Shipping Cost</strong> to the <strong>Columns</strong> shelf.</li><li>Drag <strong>Region</strong> and <strong>Shipping Method</strong> to the <strong>Rows</strong> shelf.</li><li>Drag <strong>Shipping Method</strong> to the <strong>Color</strong> box on the <strong>Marks</strong> card.</li><li>If necessary, close the <strong>Show Me</strong> pane to see the entire chart.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*hJ4rxtg_fAxKedP0reqZKw.png" /></figure><p><strong>Note</strong>: Throughout the activities, you can close the <strong>Show Me</strong> pane if you are not using it.</p><ol><li>Create another horizontal bar chart showing <strong>Shipping Cost</strong> by <strong>Region</strong> and <strong>Shipping Method</strong> for the year <strong>2024</strong>.</li><li>Right-click the sheet tab and select <strong>Duplicate</strong> to create a copy of the bar chart.</li><li>Rename the duplicate sheet as 2024 Shipping Cost by Region and Method</li><li>Drag <strong>Ship Date</strong> to the <strong>Filters</strong> shelf.</li><li>In the dialog box, select <strong>Years</strong> and then select <strong>Next</strong>.</li><li>Check <strong>2024</strong> and select <strong>OK</strong>.</li><li>The results are not satisfactory because the data source contains only a few sales for 2024. However, there was another Excel spreadsheet that had 2024 data.</li><li>Replace the data source for this worksheet.</li><li>Select <strong>Data→New Data Source</strong>, select <strong>Microsoft Excel</strong>, and then connect to <strong>MFS_Data.xlsx</strong>.</li><li>On the <strong>Data Source</strong> page, drag <strong>2024 Q1</strong> to the canvas.</li><li>Select the <strong>2024 Shipping Cost by Region and Method</strong> sheet and select <strong>Data→Replace Data Source</strong>.</li><li>In the dialog box, verify that the <strong>Current</strong> data source and the <strong>Replacement</strong> data source match the image.</li><li>Under the <strong>Current</strong> field, check the <strong>Replace current worksheet only</strong> check box to limit the data source replacement to the active sheet.</li><li>Select <strong>OK</strong>.</li><li>Some adjustments are required to get the intended result. The filter isn’t required, and some of the pills are now red. The red indicates that the replacement data source does not recognize the field names that were used in the original data source.</li><li>Modify the worksheet.</li><li>Remove <strong>YEAR(Ship Date): 2024</strong> from the <strong>Filters</strong> shelf.<br> Remember, to remove a pill from a shelf, right-click the pill and select <strong>Remove</strong>.</li><li>In the <strong>Data</strong> pane, hover over the <strong>Shipping Method</strong> field.</li><li>In the <strong>Data</strong> pane, right-click <strong>Shipping Method</strong> and select <strong>Replace References</strong>.</li><li>In the dialog box, select <strong>Ship Method</strong> and then select <strong>OK</strong>.</li><li>For <strong>Region</strong>, replace the reference with <strong>Territory</strong>.</li><li>Now the chart shows the information you need.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aae6388198c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sentiment Analysis Using BERT on IMDB: Fine-Tune Base Model on Custom Dat]]></title>
            <link>https://medium.com/@nsidana123/sentiment-analysis-using-bert-on-imdb-fine-tune-base-model-on-custom-dat-f2c6e6b24770?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2c6e6b24770</guid>
            <category><![CDATA[mls]]></category>
            <category><![CDATA[bert]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Tue, 11 Feb 2025 21:27:54 GMT</pubDate>
            <atom:updated>2025-02-12T18:57:51.240Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sentiment Analysis Using BERT on IMDB: Fine-Tune Base Model</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SssgPPRyJMVpzdt1iBa66g.jpeg" /></figure><p>Sentiment analysis, the task of classifying text as positive, negative or neutral, is one of the most widely used applications of natural language processing (NLP). With the rise of powerful pre-trained language models like BERT (Bidirectional Encoder Representations from Transformers), it‘s now possible to build highly accurate sentiment classifiers with relatively little labeled training data.</p><p>In this post, we‘ll walk through the process of fine-tuning a pre-trained BERT model for sentiment analysis using Google Colab, a free cloud-based Jupyter notebook environment. By the end, you‘ll know how to build a state-of-the-art sentiment model that can be trained in a matter of hours using a GPU runtime. Let‘s dive in!</p><h3>A Quick Primer on BERT</h3><p>BERT, developed by researchers at Google, is a transformer-based neural network architecture pre-trained on a massive amount of unlabeled text data. This pre-training allows BERT to learn contextual representations of words that capture both syntax and semantics. Specifically, BERT is trained on two unsupervised tasks:</p><ol><li><strong>Masked language modeling (MLM): </strong>Randomly masking out 15% of tokens in the input and training the model to predict the masked words based on context</li><li><strong>Next sentence prediction (NSP): </strong>Training the model to predict whether two sentences follow each other or are randomly paired</li></ol><p>This pre-training enables BERT to be fine-tuned with just one additional output layer to create state-of-the-art models for a wide range of NLP tasks, including sentiment analysis. Instead of training a model from scratch, which requires a large labeled dataset, fine-tuning allows us to leverage the knowledge BERT has gained in pre-training and adapt it to a specific task with relatively few training examples.</p><p><em>BERT pre-training and fine-tuning for downstream tasks (Source: </em><a href="https://arxiv.org/abs/1810.04805"><em>BERT paper</em></a><em>)</em></p><p>Two key concepts to understand about BERT:</p><ol><li><strong>Input representation</strong>: To handle a variety of downstream tasks, BERT represents each input example as a sequence of tokens (subword units), with special delimiting tokens [CLS] and [SEP]. Token embeddings, segment embeddings and position embeddings are summed to get a final input representation.</li><li><strong>Attention mechanism</strong>: BERT uses self-attention to compute attention weights between all pairs of input tokens, allowing it to capture long-range dependencies and learn context-dependent representations.</li></ol><p>With that background, let‘s walk through fine-tuning BERT for sentiment analysis in Google Colab. We‘ll be using the PyTorch implementation of BERT from the transformers library by Hugging Face.</p><h3>Step 1: Set Up the Colab Environment</h3><p>First, let‘s set up our Colab environment by enabling GPU acceleration and installing the necessary libraries. Go to Edit &gt; Notebook Settings, select GPU from the Hardware accelerator drop-down, and click Save.</p><p>Next, install the transformers and datasets libraries by running the following in a code cell:</p><pre>!pip install transformers datasets</pre><h3>Step 2: Load Pre-trained BERT Model and Tokenizer</h3><p>Now we‘ll load a pre-trained BERT model and its associated tokenizer. We‘ll use the ‘bert-base-uncased‘ model, which has 12 layers, 768 hidden units, and 12 attention heads. The ‘uncased‘ version converts all text to lowercase before tokenization.</p><pre>from transformers import BertTokenizer, BertForSequenceClassification</pre><pre>model_name = &quot;bert-base-uncased&quot;<br>tokenizer = BertTokenizer.from_pretrained(model_name)<br>model = BertForSequenceClassification.from_pretrained(model_name, num_labels=2)</pre><p>The BertForSequenceClassification model adds a single linear layer on top of the pooled output for classification.</p><h3>Step 3: Prepare the Sentiment Analysis Dataset</h3><p>For this tutorial, we‘ll use the popular IMDB movie reviews dataset for binary sentiment classification. The dataset contains 50,000 reviews split evenly into 25k train and 25k test sets, with an equal number of positive and negative reviews.</p><p>We‘ll load the dataset using the datasets library:</p><pre>from datasets import load_dataset</pre><pre>imdb_dataset = load_dataset(&quot;imdb&quot;)</pre><p>Before feeding the reviews to BERT, we need to preprocess them into the expected format of input IDs and attention masks. We‘ll use the tokenizer to tokenize and encode the reviews:</p><pre>def tokenize(batch):<br>    return tokenizer(batch[‘text‘], padding=True, truncation=True)</pre><pre>imdb_encoded = imdb_dataset.map(tokenize, batched=True, batch_size=None)</pre><p>This applies the tokenizer to the ‘text‘ column and returns input IDs (numeric token repsentations), attention masks (differentiates padding from actual tokens), and token type IDs (used to distinguish different sequences).</p><h3>Step 4: Fine-tune BERT</h3><p>Now we‘re ready to fine-tune our BERT model on the IMDB sentiment dataset. We‘ll use the Trainer API from transformers for easy training.</p><p>First, let‘s define our training arguments:</p><pre>from transformers import TrainingArguments</pre><pre>batch_size = 16<br>epochs = 2<br>learning_rate = 2e-5</pre><pre>training_args = TrainingArguments(<br>    output_dir=&quot;./results&quot;,          <br>    num_train_epochs=epochs,             <br>    per_device_train_batch_size=batch_size,   <br>    per_device_eval_batch_size=batch_size,   <br>    warmup_steps=500,                <br>    weight_decay=0.01,               <br>    logging_dir=&quot;./logs&quot;,            <br>)</pre><p>The key parameters are:</p><ul><li>num_train_epochs: Number of epochs to train for</li><li>per_device_train_batch_size: Batch size per GPU</li><li>learning_rate: Learning rate for the AdamW optimizer</li><li>warmup_steps: Number of warmup steps for learning rate scheduler</li></ul><p>We‘ll use the default AdamW optimizer and linear learning rate scheduler. A key best practice is to use a low learning rate (2e-5 to 5e-5) when fine-tuning BERT.</p><p>Next, define the Trainer:</p><pre>from transformers import Trainer</pre><pre>trainer = Trainer(<br>    model=model,                        <br>    args=training_args,                 <br>    train_dataset=imdb_encoded[&quot;train&quot;],<br>    eval_dataset=imdb_encoded[&quot;test&quot;]<br>)</pre><p>And finally, start training!</p><pre>trainer.train()</pre><p>On a Colab GPU runtime, this should take around 20 minutes to train. You can monitor training progress and validation metrics in the Colab output.</p><h3>Step 5: Evaluate on Test Set</h3><p>Once the model is fine-tuned, let‘s evaluate it on the test set:</p><pre>eval_results = trainer.evaluate(eval_dataset=imdb_encoded[&quot;test&quot;])<br>print(f&quot;Eval results: {eval_results}&quot;)</pre><p>After 2 epochs of fine-tuning, the BERT model reaches around 93% accuracy on the IMDB test set, which is comparable to state-of-the-art models. Not bad for a few hours of training on a single GPU!</p><p>It‘s always a good idea to dig into the model‘s errors to see where it‘s struggling and get ideas for improving performance. A confusion matrix can help identify issues like “the model has more false positives than false negatives”. Other error analysis ideas:</p><ul><li>Look at the distribution of wrong predictions across different lengths of input text</li><li>Examine a random sample of errors and look for patterns, e.g. “the model struggles with negation”</li><li>Check specific keywords or phrases that trigger errors</li></ul><p><a href="https://colab.research.google.com/drive/10SSIeNxq2iHrmNuIJkyLwTcrQ1oo3GNs?usp=sharing">Google Colab</a></p><h3>Taking It Further</h3><p>We‘ve walked through fine-tuning a basic BERT model for sentiment analysis, but there are many ways to extend and improve upon this:</p><ul><li>Use a larger or more optimized pre-trained model like RoBERTa or XLNet</li><li>Experiment with different learning rates, batch sizes, epochs, etc.</li><li>Try techniques like gradual unfreezing to mitigate overfitting</li><li>Augment the training data with rule-based transformations</li><li>Use domain-specific language models for specialized applications</li></ul><p>I encourage you to try fine-tuning BERT on your own dataset and see how it performs. The combination of transformer models and transfer learning has truly revolutionized NLP over the past few years, making powerful applications like sentiment analysis more accessible than ever.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2c6e6b24770" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ViT and VILT 2025 Series — Part1:  Vision Transformers (An Introduction)]]></title>
            <link>https://medium.com/@nsidana123/vit-and-vilt-2025-series-part1-vision-transformers-an-introduction-19a5590d9497?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/19a5590d9497</guid>
            <category><![CDATA[mls]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[dl]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Thu, 06 Feb 2025 23:12:43 GMT</pubDate>
            <atom:updated>2025-02-07T21:58:39.986Z</atom:updated>
            <content:encoded><![CDATA[<h3>ViT and VILT 2025 Series — Part1: Vision Transformers (An Introduction)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M-pnnDRCZNstgpHF.png" /></figure><p>So-called generative AI is not just about large language models (LLMs). Processing and understanding other formats like Images, and videos are equally important.</p><p>In this article, I will try to give a non-technical overview of ViT (Vision Transformers), that have emerged as successors of CNN in Computer Applications like image classification, object detection, and semantic image segmentation.</p><p>ViT model architecture was introduced in “An Image is Worth 16*16 Words: Transformers for Image Recognition at Scale”. If you want, you can give it a try: [<a href="https://arxiv.org/abs/2010.11929">https://arxiv.org/abs/2010.11929</a>]. Here, I intend to touch upon it. It is a researchers work to go deep, and I am currently not a researcher. My role is to understand and apply. And always remembering that new technologies will come.</p><p>But let me begin from the beginning. The Transformer Architecture.</p><p>The key idea behind the success of transformers is attention. It helps us consider the context of words and focus attention on the key relationships between different tokens.</p><p>Attention is about comparing ‘token embeddings’ and calculating a sort of alignment score that encapsulates how similar two tokens are based on their contextual and semantic meaning.</p><p>In the layers preceding the attention layer, each word embedding is encoded into a <em>“vector space”</em>. In this vector space, similar tokens share a similar location (a key idea behind the success of embeddings). Mathematically, dot product of two similar embeddings will result in higher alignment score compared to embeddings that are not aligned.</p><p>Before attention, our tokens’ initial positions are based purely on a “general meaning” of a particular word or sub-word token. But as we go through several encoder blocks (these include the attention mechanism), the position of these embeddings is updated to better reflect the meaning of a token <em>with respect</em> to its context. The context being all of the other words within that specific sentence.</p><blockquote><em>In other words, the tokens are pushed towards its context-based meaning through many attention encoder blocks.</em></blockquote><p>This is what pretraining language models essentially is.</p><p>Now, we can apply attention in CNNs. But attention in CNNs is computationally limited. It is a heavy operation and does not scale to large sequences. Therefore, it can <em>only</em> be used in later CNN layers — where the number of pixels are less. This limits the potential benefit of attention as it cannot be applied across the complete set of network layers.</p><p>Transformer models do not have this limitation and instead apply attention over many layers.</p><blockquote><em>So, what is ViT about?</em></blockquote><p>As I see it, it is just (preprocessing image into a suitable format) + (pushing it toseries of transformers blocks).</p><p>The high-level process for doing this is as follows:</p><ol><li>Split the image into image patches.</li><li>Process patches through the linear projection layer to get initial patch embeddings.</li><li>Preappend trainable <em>“class”</em> embedding to patch embeddings.</li><li>Sum patch embeddings and <em>learned positional embeddings</em>.</li></ol><p>After these steps, we process the patch embeddings like token embeddings in a typical transformer. Let’s dive into each of these components in more detail.</p><p><strong>1. To Image patches:</strong> Our first step is the transformation of images into image patches. In NLP, we do the same thing — we transform the sentences into tokens. It is not very hard to imagine if you know LLMs. Images are sentences and patches are word or sub-word tokens.</p><blockquote><em>NLP transformers and ViT both split larger sequences (sentences or images) into tokens or patches.</em></blockquote><p><strong>2. Linear Projection: </strong>After building the image patches, a <em>linear projection</em> layer is used to map the image patch <em>“arrays”</em> to <em>patch embedding “vectors”</em>.</p><p>The linear projection layer attempts to transform arrays into vectors while maintaining their “physical dimensions”. Meaning similar image patches should be mapped to similar patch embeddings.</p><p>By mapping the patches to embeddings, we now have the correct dimensionality for input into the transformer.</p><p><strong>3. Learnable Embeddings: </strong>One <em>feature</em> introduced to transformers with the popular BERT models was the use of a <strong>[CLS]</strong> (or <em>“classification”</em>) token. The <strong>[CLS]</strong> token was a <em>“special token”</em> prepended to every sentence fed into BERT.</p><p>This <strong>[CLS]</strong> token is converted into a token embedding and passed through several encoding layers.</p><p>Two things make <strong>[CLS]</strong> embeddings special.</p><ol><li>First, it does <em>not</em> represent an actual token, meaning it begins as a “blank slate” for each sentence.</li><li>Second, the final output from the <strong>[CLS]</strong> embedding is used as the input into a classification head during pretraining.</li></ol><p>Using a “blank slate” token as the sole input to a classification head pushes the transformer to learn to encode a <em>“general representation”</em> of the entire sentence into that embedding. The model <em>must</em> do this to enable accurate classifier predictions.</p><p>ViT applies the same logic by adding a <em>“learnable embedding”</em>. This learnable embedding is the same as the <strong>[CLS]</strong> token used by BERT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RFWkJKHrvMURoFeo.png" /></figure><p>The preferred pretraining function of ViT is based solely on classification, unlike BERT, which uses masked language modeling. Based on that, this learning embedding is <em>even more</em> important to the successful pretraining of ViT.</p><p><strong>4. Positional Embeddings: </strong>Positional embeddings enable<strong> </strong>the model to infer the <em>order</em> or <em>position</em> of the puzzle pieces. For ViT, these positional embeddings are learned vectors with the same dimensionality as our patch embeddings.</p><p>After creating the patch embeddings and prepending the “class” embedding, we sum them all with positional embeddings.</p><p>These positional embeddings are learned during pretraining and (sometimes) during fine-tuning. During training, these embeddings converge into vector spaces where they show <em>high similarity</em> to their neighboring position embeddings — particularly those sharing the same column and row.</p><p>After adding the positional embeddings, our <em>patch embeddings</em> are complete. From here, we process the embeddings into a typical transformer model.</p><p>Colab Notebook. Forked from respected Authors:</p><p>Original:</p><p><a href="https://colab.research.google.com/drive/10ZNl8qPB9QRGNQi0LcY8gJhKSlytYFPQ?usp=sharing">Google Colab</a></p><p>Tensorflow 2025 Updated Addon error Fixed:</p><p><a href="https://colab.research.google.com/drive/1bQfYnrBQ1NwUa83qENC38YfSuZICYiBP?usp=sharing">Google Colab</a></p><p>This notebook demonstrates how to use the JAX implementation of the Vision Transformer (ViT) and MLP-Mixer models for image classification. Here’s a summary of the key steps:</p><ul><li><strong>Setup</strong>: It clones the Vision Transformer repository from GitHub and installs necessary dependencies.</li><li><strong>Imports</strong>: Imports necessary libraries like Flax, JAX, and others for model training and evaluation.</li><li><strong>Load Dataset</strong>: Loads a dataset (CIFAR-10 by default) for training and evaluation. You can switch to CIFAR-100 as well if you want.</li><li><strong>Load Pre-trained Model</strong>: Downloads a pre-trained ViT or MLP-Mixer model. Options include ViT-B_32 and Mixer-B_16.</li><li><strong>Evaluate</strong>: Evaluates the pre-trained model’s accuracy on the test set.</li><li><strong>Fine-tune</strong>: Fine-tunes the pre-trained model on the training set to improve accuracy.</li><li><strong>Inference</strong>: Demonstrates how to use the fine-tuned model for inference on a new image, optionally downloaded from the internet (picsum.photos)</li></ul><p><a href="https://colab.research.google.com/drive/1BZ3LPJe8osZdT1mYSPpYiFKHyV3OjGIx?usp=sharing">Google Colab</a></p><p><strong>Step-by-step explanation:</strong></p><ul><li><strong>patches.shape[1]:</strong> This part of the code accesses the shape of the patches object (likely a NumPy array). shape is an attribute of NumPy arrays that returns a tuple representing the dimensions of the array. [1] selects the second element of this tuple, which corresponds to the number of columns in the patches array.</li><li>In simpler terms, it gets the number of columns in your patches data.</li><li><strong>np.sqrt(...):</strong> This applies the square root function from the NumPy library (np) to the number of columns obtained in the previous step.</li><li>It calculates the square root of the number of columns.</li><li><strong>int(...):</strong> This converts the result of the square root calculation into an integer. This is done because the square root might result in a floating-point number, and we need an integer for the subsequent usage of n.</li><li>It rounds down the result to the nearest whole number.</li><li><strong>n = ...:</strong> Finally, the calculated integer value is assigned to the variable n.</li><li>It stores the final whole number in a variable called ‘n’.</li></ul><p><strong>Reasoning:</strong></p><p>This line of code is commonly used in computer vision tasks, specifically when dealing with image patches.</p><ul><li><strong>Image patches</strong> are small, square sections of an image extracted for processing.</li><li>The code assumes that the patches array is structured such that it contains these flattened patches in its columns.</li><li>By calculating the square root of the number of columns and rounding it down to the nearest integer, the code aims to determine the side length (n) of these square patches.</li><li>This value is likely used in later stages of the vision task to reshape the patches back into their original square form.</li></ul><p><strong>Example:</strong></p><p>If patches.shape[1] was 16 (meaning there are 16 columns representing flattened patches), then n would be calculated as:</p><pre>n = int(np.sqrt(16))  # n becomes 4</pre><pre>patches = tf.image.extract_patches(<br>            images=images,<br>            sizes=[1, self.patch_size, self.patch_size, 1],<br>            strides=[1, self.patch_size, self.patch_size, 1],<br>            rates=[1, 1, 1, 1],<br>            padding=&quot;VALID&quot;,</pre><h3><strong>Purpose:</strong></h3><p>This code uses the tf.image.extract_patches function from TensorFlow to extract patches from an image or a batch of images. This is a common preprocessing step in computer vision tasks, particularly when using Vision Transformers (ViT) or other models that operate on image patches.</p><p><strong>Step-by-step explanation:</strong></p><ul><li><strong>tf.image.extract_patches:</strong> This is the function call from TensorFlow&#39;s image processing module that performs the patch extraction.</li><li>It’s a TensorFlow function to divide an image into smaller squares.</li><li><strong>images=images:</strong> This argument specifies the input image or batch of images from which patches will be extracted. It assumes that there&#39;s a variable called images containing the image data.</li><li>It tells the function which image to process.</li><li><strong>sizes=[1, self.patch_size, self.patch_size, 1]:</strong> This argument defines the size of the patches to be extracted. It&#39;s a list with four elements representing [batch, height, width, channels].</li><li>self.patch_size is likely an attribute of your class or object and determines the height and width of the patches in pixels.</li><li>The 1 values at the beginning and end correspond to the batch size and the number of channels, which are kept unchanged.</li><li>It sets the dimensions of the smaller squares.</li><li><strong>strides=[1, self.patch_size, self.patch_size, 1]:</strong> This argument controls the step size (in pixels) when sliding the patch extraction window across the image. Having the same values as sizes means there&#39;s no overlap between patches.</li><li>It dictates how many pixels to shift the cutting window for the next square.</li><li>With no overlap, each pixel is used in only one patch.</li><li><strong>rates=[1, 1, 1, 1]:</strong> This argument sets the sampling rate for patch extraction. A rate of 1 means that every pixel within the patch window is included. Higher rates would skip pixels, resulting in downsampling.</li><li>It determines the pixel selection frequency within the cutting window.</li><li>Here, it’s set to 1, which means every pixel is taken.</li><li><strong>padding=&quot;VALID&quot;:</strong> This argument determines how the function handles patches that would extend beyond the image boundaries. &quot;VALID&quot; padding means that any incomplete patches at the edges are discarded.</li><li>It specifies the edge handling method.</li><li>In this case, ‘VALID’ ensures that only complete squares from inside the image are extracted, while partial ones near the edges are ignored.</li><li><strong>patches = ...:</strong> The result of the patch extraction, which is a TensorFlow tensor containing the extracted patches, is assigned to the variable patches.</li><li>It stores the extracted squares in a variable called ‘patches’.</li></ul><p><strong>In essence, this code takes an image, divides it into non-overlapping squares of size </strong><strong>self.patch_size x </strong><strong>self.patch_size, and stores these squares in the </strong><strong>patches variable.</strong> I hope this helps! Let me know if you have any other questions.</p><p>Let’s discuss the role of attention in learnable position embeddings and patch encoding in Vision Transformers (ViT):</p><p><strong>Attention and Learnable Position Embeddings:</strong></p><ul><li><strong>Learnable position embeddings</strong> are vectors that are added to the patch embeddings to provide information about the spatial location of each patch within the image.</li><li>These embeddings are learned during the training process, and they capture relationships between different positions in the image.</li><li><strong>Attention is not directly involved in the creation of learnable position embeddings</strong>. Instead, attention is applied <strong>after</strong> the position embeddings are added to the patch embeddings.</li><li>The <strong>combined patch and position embeddings</strong> are then fed into the Transformer encoder, where the <strong>self-attention mechanism</strong> is used to capture relationships between different patches in the image.</li></ul><p><strong>Attention and Patch Encoding:</strong></p><ul><li><strong>Patch encoding</strong> is the process of converting image patches into lower-dimensional vectors (embeddings).</li><li>This is typically done using a <strong>linear projection</strong>, where each patch is multiplied by a weight matrix.</li><li><strong>Attention is not directly involved in patch encoding either</strong>. Patch encoding is simply a way to represent image patches in a format that can be processed by the Transformer encoder.</li></ul><p><strong>Summary:</strong></p><ul><li>Attention comes into play <strong>after</strong> both learnable position embedding and patch encoding.</li><li><strong>Patch encoding</strong> creates a representation of the patches.</li><li><strong>Learnable position embeddings</strong> provide spatial information.</li><li>The <strong>self-attention mechanism</strong> within the Transformer encoder then utilizes both these to establish relationships and dependencies between the patches, ultimately enabling the model to understand the image content.</li></ul><p>In essence, attention is a key component of the Transformer encoder, but it’s applied <strong>after</strong> the patch and position embeddings are created. I hope this clarifies the roles of attention in these stages. Feel free to ask if you have any more questions</p><p>In conclusion, the Vision Transformer (ViT) architecture demonstrates that a pure transformer model can be effectively applied to sequences of image patches, achieving impressive performance on image classification tasks. Unlike Convolutional Neural Networks (CNNs), which have evolved significantly but face challenges in integrating attention mechanisms practically, Vision Transformers offer a scalable and efficient solution. This makes ViTs a promising alternative to CNNs for various computer vision applications.</p><p>Credit: Rahul S. <a href="https://arxiv.org/abs/2010.11929">This makes ViTs a promising alternative to CNNs for various computer vision applications1</a><a href="https://en.wikipedia.org/wiki/Vision_transformer">2</a><a href="https://huggingface.co/docs/transformers/model_doc/vit">3</a>.</p><p><a href="https://arxiv.org/abs/2010.11929">1</a>: <a href="https://arxiv.org/abs/2010.11929">An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale </a><a href="https://en.wikipedia.org/wiki/Vision_transformer">2</a>: <a href="https://en.wikipedia.org/wiki/Vision_transformer">Vision Transformer - Wikipedia</a><a href="https://arxiv.org/abs/2010.11929"> </a><a href="https://huggingface.co/docs/transformers/model_doc/vit">3</a>: <a href="https://huggingface.co/docs/transformers/model_doc/vit">Vision Transformer (ViT) - Hugging Face</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19a5590d9497" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Core Concepts & Techniques of AI in 2025]]></title>
            <link>https://medium.com/@nsidana123/core-concepts-techniques-of-ai-in-2025-7553797ab394?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/7553797ab394</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[mls]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Sun, 02 Feb 2025 18:50:04 GMT</pubDate>
            <atom:updated>2025-02-02T18:50:04.065Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*9ggLNsERPdK7OulOJ3385Q.jpeg" /></figure><h3><strong>The Essence of Artificial Intelligence</strong></h3><p>Artificial intelligence represents humanity’s most audacious technological endeavor creating intelligent systems that can think, learn, and adapt. At its core, AI is about simulating human cognitive functions through sophisticated mathematical models and computational architectures.</p><p>The Philosophical Underpinnings</p><p>AI transcends mere technological innovation; it’s a profound exploration of intelligence itself. By developing systems that can mimic human reasoning, we’re fundamentally challenging our understanding of cognition, learning, and problem-solving.</p><p>Machine Learning: The Heartbeat of AI intelligence</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qEPQskomTKlrF-3S_WSHjg.jpeg" /></figure><h3>Learning Paradigms: Beyond Traditional Programming</h3><p>Machine learning represents a revolutionary approach to computational intelligence. Unlike traditional programming, where explicit instructions govern every action, machine learning algorithms <strong>automatically learn insights and recognize patterns from data.</strong></p><h3>Three Transformative Learning Approaches</h3><ol><li><strong>Supervised Learning</strong></li></ol><ul><li>Uses labeled datasets</li><li>Learns by comparing actual and predicted outcomes</li><li>Ideal for classification and regression tasks</li></ul><p><strong>2. Unsupervised Learning</strong></p><ul><li>Works with unlabeled data</li><li>Discovers hidden patterns autonomously</li><li>Excels in clustering and dimensionality reduction</li></ul><ol><li><strong>Reinforcement Learning</strong></li></ol><ul><li>Learns through environmental interaction</li><li>Uses reward mechanisms to optimize decision-making</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0G1omqUCnf6Tq5FjDcuEzA.jpeg" /></figure><ul><li>Commonly applied in robotics and strategic domains</li></ul><h3>Deep Learning: Neural Networks Reimagined</h3><p>Deep learning represents the pinnacle of machine learning sophistication. By utilizing <strong>large neural networks modeled after human brain functionality</strong>, these systems can learn extraordinarily complex patterns independently.</p><h3>AI Architecture: The Strategic Blueprint</h3><p>AI architecture serves as the comprehensive framework for developing intelligent systems. It’s not just technical infrastructure but a strategic alignment between technological components and organizational objectives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZxvAajXuEGhauY_G5JKU5w.jpeg" /></figure><h3>Architectural Components</h3><p><strong>Data Layer:</strong></p><ul><li>Manages diverse data sources</li><li>Includes databases, data lakes, cloud storage</li></ul><p><strong>Processing Layer:</strong></p><ul><li>Transforms and prepares data</li><li>Enables machine learning model training</li></ul><p><strong>Algorithm Layer:</strong></p><ul><li>Houses machine learning algorithms</li><li>Trains models for prediction and decision-making</li></ul><p><strong>Interface Layer:</strong></p><ul><li>Provides user interaction points</li><li>Supports web/mobile applications and APIs</li></ul><h3>The AI Development Lifecycle: From Concept to Deployment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*IuNu9-Z5NyBvHVadXgMxJA.jpeg" /></figure><h3>Comprehensive Stages of AI System Creation</h3><ol><li><strong>Problem Definition</strong></li></ol><ul><li>Precisely identify AI system objectives</li><li>Align technological capabilities with business needs</li></ul><p><strong>2. Data Collection and Preparation</strong></p><ul><li>Gather high-quality, relevant datasets</li><li>Clean, preprocess, and engineer features</li></ul><p><strong>3. Model Design</strong></p><ul><li>Select appropriate algorithms</li><li>Define neural network architectures</li><li>Choose learning approaches</li></ul><p><strong>4. Model Training</strong></p><ul><li>Feed prepared data into algorithms</li><li>Enable iterative learning and optimization</li></ul><p><strong>5. Validation and Testing</strong></p><ul><li>Rigorously evaluate model performance</li><li>Check generalization capabilities</li></ul><p><strong>6. Deployment</strong></p><ul><li>Integrate AI system into production environments</li><li>Ensure scalability and reliability</li></ul><ol><li><strong>Continuous Monitoring</strong></li></ol><ul><li>Track model performance</li><li>Address potential algorithmic drift</li><li>Implement ongoing improvements</li></ul><h3>Transformative Applications Across Industries</h3><p>AI’s impact spans virtually every sector:</p><ul><li><strong>Healthcare:</strong> Personalized treatment plans</li><li><strong>Finance:</strong> Fraud detection</li><li><strong>Retail:</strong> Recommendation engines</li><li><strong>Manufacturing:</strong> Predictive maintenance</li><li><strong>Transportation:</strong> Autonomous vehicles</li></ul><h3>Ethical Considerations and Future Outlook</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYJqmFIrO3WDbgmf8QsAow.jpeg" /></figure><p>As AI becomes increasingly sophisticated, <strong>ethical development</strong> remains paramount. Key focus areas include:</p><ul><li>Mitigating algorithmic bias</li><li>Ensuring transparency</li><li>Protecting individual privacy</li><li>Maintaining human-centric design principles</li></ul><h3>Conclusion: The Ongoing AI Revolution</h3><p>Artificial Intelligence represents more than technological advancement — it’s a fundamental reimagining of human-machine interaction. By understanding its intricate mechanisms, we unlock unprecedented potential for solving complex global challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7553797ab394" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harnessing the Power of AI: Text-to-Video Model : Locally on single NVIDIA RTX 3090 GPU]]></title>
            <link>https://towardsdev.com/harnessing-the-power-of-ai-text-to-video-model-locally-on-single-nvidia-rtx-3090-gpu-6e8073889d8b?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e8073889d8b</guid>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[gen-ai-vision]]></category>
            <category><![CDATA[vision-transformer]]></category>
            <category><![CDATA[llm-applications]]></category>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Tue, 10 Sep 2024 15:28:58 GMT</pubDate>
            <atom:updated>2024-09-18T14:30:21.582Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*rNwb72dgWnjJi-XMT71E3A.png" /><figcaption>Video Generated By CogVideoX 2B</figcaption></figure><p>As a data scientist with over a decade of experience in artificial intelligence and machine learning, I have seen the landscape of <em>generative models</em> evolve dramatically. One of the most exciting advancements is the ability to generate videos from textual descriptions using models like <em>CogVideoX</em>. In this article, I’ll guide you through the step-by-step process of setting up and running <em>CogVideoX </em>locally on an <em>NVIDIA RTX 3090 GPU</em>, ensuring optimal performance and avoiding common pitfalls such as out-of-memory errors.</p><h3>Prerequisites</h3><p>Before we begin, ensure you have the following:</p><p>- A Linux machine with an NVIDIA RTX 3090 GPU (24 GB VRAM).<br>- Python 3.11 or above installed.<br>- Basic knowledge of Python and command-line operations.</p><h3>Step 1: Install Required System Packages</h3><p>First, we need to install Git and enable Git LFS (Large File Storage) to download the model files from Hugging Face. Open your terminal and run the following commands:</p><pre><br>sudo apt update<br>sudo apt install git-all<br>git lfs install<br></pre><h3><strong>Step 2: Set Up a Virtual Environment</strong></h3><p>Creating a virtual environment is a good practice to manage dependencies. Use the following commands to create and activate a virtual environment:</p><pre>python3 -m venv cogvideo_env<br>source cogvideo_env/bin/activate</pre><h3>Step 3: Install Necessary Python Libraries</h3><p>Now, install the required libraries, including PyTorch, Transformers, and Diffusers. Make sure to install the version of PyTorch compatible with your CUDA version (for RTX 3090, use CUDA 11.3 or higher):</p><pre>pip install torch torchvision torchaudio — extra-index-url https://download.pytorch.org/whl/cu113<br>pip install transformers diffusers accelerate ffmpeg-python<br></pre><h3>Step 4: Download the CogVideoX Model</h3><p>To download the CogVideoX model from Hugging Face, use the following command:</p><pre>git lfs clone https://huggingface.co/THUDM/CogVideoX-2b<br></pre><p><strong>Step 5: Write the Video Generation Script</strong></p><p>Now, create a Python script named `generate_video.py` and add the following code:</p><pre>python<br>import torch<br>from diffusers import CogVideoXPipeline<br>from diffusers.utils import export_to_video</pre><pre># Clear CUDA cache to avoid out-of-memory errors<br>torch.cuda.empty_cache()</pre><pre># Define your prompt for the video<br>prompt = “””Next Episode of the Story</pre><pre># Load the CogVideoX model<br>pipe = CogVideoXPipeline.from_pretrained(“/path/to/your_model”, torch_dtype=torch.float16)</pre><pre># Enable CPU offloading to optimize memory usage<br>pipe.enable_model_cpu_offload()</pre><pre># Encode the prompt<br>prompt_embeds, _ = pipe.encode_prompt(<br> prompt=prompt,<br> do_classifier_free_guidance=True,<br> num_videos_per_prompt=1,<br> max_sequence_length=226,<br> device=”cuda”,<br> dtype=torch.float16,<br>)</pre><pre># Clear CUDA cache again before generating video<br>torch.cuda.empty_cache()</pre><pre># Generate the video<br>video = pipe(<br> num_inference_steps=70,<br> guidance_scale=9,<br> prompt_embeds=prompt_embeds,<br>).frames[0]</pre><pre># Clear CUDA cache one last time before exporting<br>torch.cuda.empty_cache()</pre><pre># Export the generated video<br>export_to_video(video, “output.mp4”, fps=15)<br></pre><h3>Important Note on Memory Management</h3><p>The use of `<strong>torch.cuda.empty_cache</strong>()` is crucial in this script. It helps to clear unused memory from the GPU, preventing out-of-memory (OOM) errors during the execution of the model. Without this step, you may encounter memory fragmentation issues, especially when working with large models and high-resolution outputs.</p><h3>Step 6: Run the Script</h3><p>With everything set up, run your script using the following command:</p><pre><br>python generate_video.py</pre><p>This will generate a video based on the provided prompt and save it as `output.mp4`.</p><h3>Conclusion</h3><p>Running the CogVideoX model locally on an NVIDIA RTX 3090 GPU opens up exciting possibilities for content creation and storytelling. By following the steps outlined in this article, you can harness the power of AI to generate videos from text prompts, all while managing memory effectively to avoid common pitfalls.</p><p>As we continue to explore the capabilities of generative models, the potential applications are vast, ranging from entertainment to education and beyond. The integration of open-source tools like CogVideoX into our workflows will undoubtedly shape the future of content creation, making it more accessible and innovative.</p><h3>Final Thoughts</h3><p>The journey of working with AI and machine learning is ever-evolving. With advancements in models like CogVideoX and the growing ecosystem of tools and libraries, the possibilities are limited only by our imagination. As we move forward, let’s embrace these technologies and explore the new frontiers they open up in creativity and innovation.</p><p><strong>Citations</strong>:<br>[1] <a href="https://discuss.pytorch.org/t/torch-cuda-empty-cache-memory-segmentation-and-runtime/146385">https://discuss.pytorch.org/t/torch-cuda-empty-cache-memory-segmentation-and-runtime/146385</a><br>[2] <a href="https://discuss.pytorch.org/t/mitigating-cuda-gpu-memory-fragmentation-and-oom-issues/108203">https://discuss.pytorch.org/t/mitigating-cuda-gpu-memory-fragmentation-and-oom-issues/108203</a><br>[3] <a href="https://discuss.pytorch.org/t/about-torch-cuda-empty-cache/34232">https://discuss.pytorch.org/t/about-torch-cuda-empty-cache/34232</a><br>[4] <a href="https://stackoverflow.com/questions/63787404/why-the-cuda-memory-is-not-release-with-torch-cuda-empty-cache">https://stackoverflow.com/questions/63787404/why-the-cuda-memory-is-not-release-with-torch-cuda-empty-cache</a><br>[5] <a href="https://github.com/open-mmlab/mmskeleton/issues/263">https://github.com/open-mmlab/mmskeleton/issues/263</a><br>[6] <a href="https://www.reddit.com/r/pytorch/comments/xsmru3/cannot_clear_all_of_gpu_memory_when_using_pytorch/">https://www.reddit.com/r/pytorch/comments/xsmru3/cannot_clear_all_of_gpu_memory_when_using_pytorch/</a><br>[7] <a href="https://huggingface.co/THUDM/CogVideoX-5b">https://huggingface.co/THUDM/CogVideoX-5b</a><br>[8] <a href="https://huggingface.co/THUDM/CogVideoX-2b">https://huggingface.co/THUDM/CogVideoX-2b</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e8073889d8b" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/harnessing-the-power-of-ai-text-to-video-model-locally-on-single-nvidia-rtx-3090-gpu-6e8073889d8b">Harnessing the Power of AI: Text-to-Video Model : Locally on single NVIDIA RTX 3090 GPU</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing latest Hadoop 3.4 on Ubuntu 2024: Easy Installation Guide]]></title>
            <link>https://medium.com/@nsidana123/installing-latest-hadoop-3-4-on-ubuntu-2024-easy-installation-guide-874f889fede7?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/874f889fede7</guid>
            <category><![CDATA[hadoop]]></category>
            <category><![CDATA[hdfs]]></category>
            <category><![CDATA[hadoop-mapreduce]]></category>
            <category><![CDATA[hadoop-cluster]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Tue, 03 Sep 2024 16:36:57 GMT</pubDate>
            <atom:updated>2024-09-07T08:25:12.647Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Apache Hadoop ?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*fYoSPPdY8FAA0FhCmqkBdw.png" /></figure><p>Apache Hadoop software library is a framework that allows for the distributed processing of large data sets across clusters of computers using simple programming models. It is designed to scale up from single servers to thousands of machines, each offering local computation and storage. Rather than rely on hardware to deliver high-availability, the library itself is designed to detect and handle failures at the application layer, so delivering a highly-available service on top of a cluster of computers, each of which may be prone to failures.</p><h3><strong>Let’s Begin.</strong></h3><p>Let’s dive in, and if you encounter any glitches, refer to a guide on common errors people face during Hadoop installation.</p><p><strong>Step 1 : Install Java Development Kit</strong></p><p>The default Ubuntu repositories contain both Java 8 and Java 11. Ensure you use Java 8, as Hive is compatible only with this version. Execute the following command to install Java 8:</p><pre>sudo apt update &amp;&amp; sudo apt install openjdk-8-jdk</pre><p><strong>Step 2: Verify Java Version</strong></p><p>To verify the installed Java version, use the following command:</p><pre>java -version</pre><p><strong>Step 3: Install SSH</strong></p><p>SSH is crucial for secure communication between nodes in a Hadoop cluster. It enables secure data transfer, remote administration, and coordination among distributed components, ensuring the integrity and confidentiality of the system.</p><p>The command to install SSH on Ubuntu is:</p><pre>sudo apt install ssh<br>sudo apt-get install pdsh</pre><p><strong>Step 4: Create Hadoop User</strong></p><p>Create a user named ‘hadoop’ and set a password for secure Hadoop operations and web interface access.</p><pre>sudo adduser hadoop</pre><p><strong>Step 5: Switch User</strong></p><p>Switching to the newly created ‘hadoop’ user for Hadoop operations.</p><pre>su — hadoop</pre><p><strong>Step 6 : Configure SSH</strong></p><p>Create an SSH key for the ‘hadoop’ user without a password to enable easy and secure access.</p><pre>ssh-keygen -t rsa</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*w2ZQT2Z_5YleeAMF0BLqfw.png" /></figure><p><strong>Step 7 : Set Permission</strong></p><p>Transfer the generated public key to the authorized keys file and set permissions to ensure secure access.</p><pre>cat ~/.ssh/id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys <br>chmod 640 ~/.ssh/authorized_keys</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*RS1V7ogGe7Y8UTYZR_7tRA.png" /></figure><p><strong>Step 8 : SSH to localhost</strong></p><p>Initiate an SSH connection to localhost. Upon prompt, type ‘yes’ and press Enter to authenticate the RSA keys for secure access.</p><pre>ssh localhost</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*BnKa5r9anWrHx-1kgFlcyw.png" /></figure><p><strong>Step 9 : Switch User</strong></p><pre>su — hadoop</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*Djr92Fv1jLJCz-NU5qVBQQ.png" /></figure><p><strong>Step 10 : Install Hadoop</strong></p><ul><li>Download Hadoop 3.4 by fetching the tar.gz file from the official Apache Hadoop distribution.</li></ul><pre>wget https://dlcdn.apache.org/hadoop/common/hadoop-3.4.0/hadoop-3.4.0.tar.gz</pre><ul><li>Unzip the downloaded Hadoop file to a folder for further installation steps.</li></ul><pre>tar -xvzf hadoop-3.4.0.tar.gz</pre><ul><li>Rename the extracted Hadoop folder to ‘hadoop’ for simpler configuration and path settings.</li></ul><pre>mv hadoop-3.4.0 hadoop</pre><ul><li>Open the ~/.bashrc file using your preferred text editor. For nano, paste the code with ctrl+shift+v, save with ctrl+x and ctrl+y, then press enter.</li></ul><pre>nano ~/.bashrc</pre><ul><li>Add the following 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=”-Djava.library.path=$HADOOP_HOME/lib/native”</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*ervRks-eg-JOZJqGVX5gZw.png" /></figure><ul><li>Load the configuration changes in the current environment by sourcing the .bashrc file.</li></ul><pre>source ~/.bashrc</pre><ul><li>Open the Hadoop environment variable file in the nano text editor.</li></ul><pre>nano $HADOOP_HOME/etc/hadoop/hadoop-env.sh</pre><ul><li>In the opened file, locate the line with “export JAVA_HOME” and configure it:</li></ul><pre>JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*vMl9jQndoaxrbde_r7fMXA.png" /></figure><p><strong>Step 11 : Configuring Hadoop</strong></p><pre>cd hadoop/</pre><ul><li>Open core-site.xml to configure the Hadoop file system. Update “fs.defaultFS” with your system hostname.</li></ul><pre>nano $HADOOP_HOME/etc/hadoop/core-site.xml</pre><ul><li>Add the following lines to the file.</li></ul><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;<br></pre><ul><li>Open hdfs-site.xml to configure Namenode and Datanode directories.</li></ul><pre>nano $HADOOP_HOME/etc/hadoop/hdfs-site.xml</pre><p>Add the following lines to the file.</p><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><p>The following instructions are to run a MapReduce job locally. If you want to execute a job on YARN, see <a href="https://hadoop.apache.org/docs/r3.4.0/hadoop-project-dist/hadoop-common/SingleCluster.html#YARN_on_a_Single_Node">YARN on Single Node</a>.</p><ul><li>Format the filesystem:</li></ul><pre>bin/hdfs namenode -format</pre><ol><li>Start NameNode daemon and DataNode daemon:</li></ol><pre>sbin/start-dfs.sh</pre><p>The hadoop daemon log output is written to the $HADOOP_LOG_DIR directory (defaults to $HADOOP_HOME/logs).</p><ul><li>Browse the web interface for the NameNode; by default it is available at:</li><li>NameNode — <a href="http://localhost:9870/">http://localhost:9870/</a></li><li>Make the HDFS directories required to execute MapReduce jobs:</li></ul><pre>bin/hdfs dfs -mkdir -p /user/&lt;username&gt;</pre><ul><li>Copy the input files into the distributed filesystem:</li></ul><pre>bin/hdfs dfs -mkdir input <br>bin/hdfs dfs -put etc/hadoop/*.xml input</pre><ul><li>Run some of the examples provided:</li></ul><pre>bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.4.0.jar grep input output &#39;dfs[a-z.]+&#39;</pre><ul><li>Examine the output files: Copy the output files from the distributed filesystem to the local filesystem and examine them:</li></ul><pre>bin/hdfs dfs -get output output $ cat output/*</pre><ul><li>View the output files on the distributed filesystem:</li></ul><pre>bin/hdfs dfs -cat output/*</pre><ul><li>When you’re done, stop the daemons with:</li></ul><pre>stop-dfs.sh</pre><h3>YARN on a Single Node</h3><p>You can run a MapReduce job on YARN in a pseudo-distributed mode by setting a few parameters and running ResourceManager daemon and NodeManager daemon in addition.</p><p>Configure parameters as follows:</p><ol><li>Open mapred-site.xml to configure MapReduce framework.</li></ol><pre>nano $HADOOP_HOME/etc/hadoop/mapred-site.xml</pre><p>Add the following lines to the file.</p><pre>&lt;configuration&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;mapreduce.framework.name&lt;/name&gt;<br>        &lt;value&gt;yarn&lt;/value&gt;<br>    &lt;/property&gt;<br>    &lt;property&gt;<br>        &lt;name&gt;mapreduce.application.classpath&lt;/name&gt;<br>        &lt;value&gt;$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*:$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*&lt;/value&gt;<br>    &lt;/property&gt;<br>&lt;/configuration&gt;* </pre><ul><li>Open yarn-site.xml to configure YARN settings.</li></ul><pre>nano $HADOOP_HOME/etc/hadoop/yarn-site.xml</pre><ul><li>Add the following lines to the file.</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;property&gt;<br>        &lt;name&gt;yarn.nodemanager.env-whitelist&lt;/name&gt;<br>        &lt;value&gt;JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_HOME,PATH,LANG,TZ,HADOOP_MAPRED_HOME&lt;/value&gt;<br>    &lt;/property&gt;<br>&lt;/configuration&gt;</pre><ul><li>Start ResourceManager daemon and NodeManager daemon:</li></ul><pre>sbin/start-yarn.sh</pre><ul><li>Browse the web interface for the ResourceManager; by default it is available at:</li></ul><p>ResourceManager — <a href="http://localhost:8088/">http://localhost:8088/</a></p><ul><li>Run a MapReduce job.</li><li>When you’re done, stop the daemons with:</li></ul><pre>sbin/stop-yarn.sh</pre><p><strong>Step 12 : Start Hadoop Cluster</strong></p><p>Format the Hadoop Namenode before starting the cluster.</p><pre>hdfs namenode -format</pre><ul><li>Initiate the Hadoop cluster with the start-all.sh command.</li></ul><pre>start-all.sh</pre><ul><li>Verify the status of Hadoop services using the jps command.</li></ul><pre>jps</pre><p><strong>Step 13 : Access Hadoop Namenode and Resource Manager</strong></p><ul><li>Install net-tools and find your server’s IP address using ifconfig</li></ul><pre>sudo apt install net-tools</pre><pre>ifconfig</pre><ul><li>Access the Loaclhost</li></ul><p>To access the Namenode, open your web browser and visit the URL <a href="http://localhost:9870/">http://localhost:9870</a>. You should see the following screen:</p><p>To access Resource Manage, open your web browser and visit the URL <a href="http://localhost:8088/">http://localhost:8088</a>. You should see the following screen:</p><h3>Conclusion:</h3><p><em>Congratulations</em>! You’ve completed the step-by-step tutorial on installing and configuring Hadoop on Ubuntu . You’re now ready to delve into the world of big data analytics. Happy exploring! create impressive and simple conclusion. Please consider giving a clap if you liked reading the article as it helps me create more useful content. In the next article, Let’s explore the open source distributions in the world of distributed computing using the hadoop ecosystem. Happy Learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=874f889fede7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Is Next.Js 15 Revolutionizing Web App Development?]]></title>
            <link>https://medium.com/@nsidana123/why-is-next-js-15-revolutionizing-web-app-development-07feeec71688?source=rss-c2a1c1bea4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/07feeec71688</guid>
            <dc:creator><![CDATA[Navdeep Sidana]]></dc:creator>
            <pubDate>Sat, 20 Jul 2024 14:47:39 GMT</pubDate>
            <atom:updated>2024-07-20T14:47:39.245Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*oE2UjN3i1bfBPx6gOI7J2g.jpeg" /><figcaption>Understanding Web Development</figcaption></figure><p><a href="https://nextjs.org/">NextJS</a> 15 Release Candidate (RC) introduces a range of new features &amp; improvements aimed at enhancing the development experience and performance of web applications. This release builds on the strengths of the previous version while at the same time introducing innovative capabilities that promise to streamline workflows and optimize application performance. Below is a detailed overview of the key updates in NextJS 15 RC.</p><h3>What is NextJS?</h3><p>Next.js is an open-source web development framework built on top of ReactJS library, that enables the creation of high-performance, scalable applications with Server-Side Rendering (SSR), Static Site Generation (SSG), Incremental Static Regeneration (ISR), simplified routing, image optimization, code splitting, middleware, etc.</p><p>Developed and maintained by <a href="https://vercel.com/">Vercel</a>, Next.js simplifies the development process by providing a standard structure and built-in solutions for common web development challenges, allowing NextJS development company to focus on writing code in React rather than configuring tools.</p><h3>What’s New with NextJs 15 RC</h3><p>To try the latest NextJS 15 use the following command:</p><pre>npm install next@rc react@rc react-dom@rc</pre><p>Exciting news for NextJS developers looking to jumpstart their next project! The CLI tool now includes a handy new — empty flag to strip away all the extra fluff. With a single command, you can generate a pristine, minimal “Hello World” page as your starting point.:</p><pre>npx create-next-app@rc --empty</pre><h3>Support for React 19 RC</h3><p>Next.js 15 RC fully supports React 19 RC, including the new React Compiler, which is currently in an experimental phase. This integration promises significant performance enhancements and more efficient hydration error handling. The React Compiler aims to optimize code automatically, reducing the need for manual optimizations using hooks like <em>useMemo</em> and <em>useCallback.</em></p><h3>Revamped Caching Strategies</h3><p>Introduced configurable invalidation periods in Next.js 14.2 with <em>staleTimes </em>for client-side router cache, allowing NextJS developers to control cache invalidation more precisely. One of the major changes in Next.js 15 RC is the overhaul of caching strategies. <em>fetch</em> requests, <em>GET</em> route handlers, and client-side navigations are no longer cached by default.</p><p>This change ensures that the data served is always fresh, reducing the chances of displaying outdated information to users. NextJS development company now have more control over caching behaviors, allowing for more precise optimization of application performance.</p><p>To enable caching for specific requests, you can use the cache:<em> ‘force-cache’</em> option:</p><pre>fetch(&#39;https://...&#39;, { cache: &#39;force-cache&#39; });</pre><h3>Partial Prerendering (Experimental)</h3><p>Next.js 15 introduces an experimental feature called Partial Prerendering (PPR). Building upon the foundations laid in Next.js 14, PPR allows developers to incrementally adopt a hybrid rendering approach.</p><p>With PPR, you can wrap dynamic UI components in a Suspense boundary and opt-in specific Layouts and Pages for partial prerendering. When a request comes in, Next.js will immediately serve a static HTML shell and then render and stream the dynamic parts in the same HTTP request. To enable PPR, set the <em>experimental.ppr</em> config option to <em>‘incremental’</em> in <em>next.config.js</em>:</p><pre>const nextConfig = {<br>  experimental: {<br>    ppr: &#39;incremental&#39;,<br>  },<br>};<br></pre><pre>module.exports = nextConfig;</pre><p>Once all segments have PPR enabled, you can set <em>ppr</em> to <em>true</em> to enable it for the entire application.</p><h3>New next/after API (Experimental)</h3><p>The<em> next/after</em> API is another experimental feature in Next.js 15 RC. This feature enables developers to perform secondary tasks or cleanup operations without blocking the primary response. This addition provides more flexibility in handling post-response logic, allowing for cleaner and more efficient code management. Potential use cases include analytics logging, resource cleanup, or additional data fetching after the initial response.</p><p>To use it, add <em>experimental.after </em>to <em>next.config.js</em>:</p><pre>const nextConfig = {<br>  experimental: {<br>    after: true,<br>  },<br>};</pre><pre>module.exports = nextConfig;</pre><p>Here’s an example of how to use <em>next/after</em>:</p><pre>import { unstable_after as after } from &#39;next/server&#39;;</pre><pre>export default function Layout({ children }) {<br>// Secondary task<br>after(() =&gt; {<br>console.log(&#39;Response finished streaming&#39;);<br>});<br>// Primary task<br>return &lt;&gt;{children}&lt;/&gt;;<br>}</pre><h3>create-next-app Updates</h3><p>The create-next-app tool, used for generating new Next.js projects, has received a fresh new design in Next.js 15 RC. Additionally, it now includes a flag to enable Turbopack (defaults to No).</p><p>Turbopack is a high-performance JavaScript bundler <a href="https://nextjs.org/docs/architecture/turbopack#:~:text=Turbopack%20replaces%20Webpack%2C%20this%20means%20that%20webpack%20configuration%20is%20not%20supported.">designed to replace Webpack</a>, offering faster build times and an improved development workflow. This update simplifies the setup process and enhances the overall development experience.</p><p>To enable Turbopack:</p><pre>&quot;scripts&quot;: {<br>&quot;dev&quot;: &quot;next dev --turbo&quot;,<br>&quot;build&quot;: &quot;next build&quot;,<br>&quot;start&quot;: &quot;next start&quot;,<br>&quot;lint&quot;: &quot;next lint&quot;<br>}</pre><h3>Bundling External Packages (Stable)</h3><p>Next.js 15 introduces stable configuration options for optimizing the bundling of external packages in both the App Router and Pages Router. These improvements aim to enhance cold-start performance and provide developers with more control over how external dependencies are included in their applications.</p><h3>Hydration Error Improvements</h3><p>Hydration errors, which occur due to mismatches between server-rendered and client-rendered content, have been a common issue in Next.js. Building upon the enhancements made in Next.js 14.1, Next.js 15 further improves the NextJS developer experience when encountering hydration errors. The hydration error view now includes more informative error messages, source code snippets, and suggestions for resolving the issues, making debugging more efficient.</p><h3>Final Thoughts</h3><p>While Next.js 15 RC is not yet the official major release, companies and developers should not wait to explore its potential. Embracing the opportunity to experiment and test new features in the Next.Js 15 RC version allows for a smoother transition and faster adoption once the official release is available. By getting a head start with Next.js 15 RC, you’ll be well-prepared to leverage its full capabilities.</p><p>Next.js 15 Release Candidate brings a wealth of new features &amp; improvements to the existing system that empower the Next.js development company to build high-performance, dynamic web applications with ease. From React 19 RC support to caching updates, partial prerendering, &amp; developer experience enhancements, this Next.js 15 release sets the stage for the future of Next.js development.</p><p>As always, it’s of utmost importance to carefully evaluate these new features, test them thoroughly, &amp; provide feedback to the Next.js team. By collaborating with the <a href="https://nextjs.org/docs/community">community</a>, we can shape the direction of Next.js &amp; create even more powerful &amp; efficient web applications.</p><p>Tired of Slow &amp; Clunky Web Apps? It’s time for a NextJS development service upgrade! <a href="https://www.solutelabs.com/">Solutelabs</a> is a <a href="https://www.solutelabs.com/reactjs-development-services">ReactJS Development Company</a> that will transform your website into a high-performance machine. Curious to see what’s possible? <a href="https://www.solutelabs.com/contact">Reach out</a> &amp; let’s have some fun building the future of your web presence.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07feeec71688" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>