Union Find Problem, and a naive implementation (C++)

Hi Everyone, today I want to talk about Union Find Problem. This is going to be a series covering: Union Find Problem (this blog) Solutions to Union Find (1): Quick Find Solutions to Union Find (2): Quick Union Solutions to Union Find (3): Weighted Quick Union Applications of Union Find (perculation and more) Cool project using Union Find Solving some competitive programming questions using Union Find Each blog will try to cover very basic concepts behind the topic, and also what it’s all about. ...

August 14, 2021 · 7 min · Kushashwa Ravi Shrimali

Prefer Alias Declarations to Typedefs (Notes)

One solution to avoiding using long type names: // So C++98 like typedef std::unique_ptr<std::unordered_map<std::string, std::string>> UPtrMapSS; ...

August 12, 2021 · 3 min · Kushashwa Ravi Shrimali

Function Pointers and Function Objects in C++

In today’s blog, we’ll talk about two important concepts in C++: Function Pointers and Function Objects. Please note that, function objects are commonly referred as functors but we have failed to notice any official alias to the name. Hence, we’ll restrict ourselves to using Function Objects in this blog. ...

July 18, 2021 · 9 min · Kushashwa Ravi Shrimali

Releasing Docker Container and Binder for using Xeus-Cling, Libtorch and OpenCV in C++

Today, I am elated to share Docker image for OpenCV, Libtorch and Xeus-Cling. We’ll discuss how to use the dockerfile and binder. Before I move on, the credits for creating and maintaining Docker image goes to Vishwesh Ravi Shrimali. He has been working on some cool stuff, please do get in touch with him if you’re interested to know. First question in your mind would be, Why use Docker or Binder? The answer to it lies in the frequency of queries on the discussion forum of PyTorch and Stackoverflow on Installation of Libtorch with OpenCV in Windows/Linux/OSX. I’ve had nightmares setting up the Windows system myself for Libtorch and nothing could be better than using Docker. Read on, to know why. ...

September 15, 2020 · 3 min · Kushashwa Ravi Shrimali

Understanding how Vectors work in C++ (Part-2): What happens when you initialize a vector?

In the last blog post, I realized there were a lot of methods inherited from the base struct _Vector_base_ and _Vector_impl_data. Instead of directly going to the source code of these structs, I’ll go through their methods and objects by explaining what happens when we initialize a vector. That is, we will start from calling a vector constructor and then see how memory is allocated. If you haven’t looked at the previous blog post, please take a look here. I want to be thorough with the blog post, so I’ll divide this into multiple posts. By the end of this post, you’ll go through the following structs: ...

April 26, 2020 · 7 min · Kushashwa Ravi Shrimali

Understanding how Vectors work in C++ (Part-3): Diving deep into member functions of vectors

In this blog, we’ll continue diving deep into the source code of Vector Containers in GCC compiler. Today, we will be discussing some of the most commonly used methods of vectors, and how they are implemented. Before we start, if you haven’t looked at the previous blogs in the C++ series, please take a look here. If you are already familiar with memory allocation in vector containers and vector’s base structs, then you can skip reading the previous blogs and continue here. If not, I suggest you reading them. ...

April 26, 2020 · 7 min · Kushashwa Ravi Shrimali

Understanding how Vectors work in C++ (Part-1): How does push_back work?

This blog is focused to explain how vectors work in the backend, and we’ll specially look at push_back method of the vector container. Looking at the source code helps to understand the implementation, and how vectors can be used efficiently. Vector Containers are type of sequenced containers in C++ commonly uses as a better alternative of arrays. They are also known as dynamic arrays, and as the term suggests - it’s one of the advantages they hold over native arrays in C++. You might have heard of Standard Library containers like vector, set, queue, priority_queue before. They all implement methods defined by the Container Concept. ...

April 18, 2020 · 7 min · Kushashwa Ravi Shrimali

[Training and Results] Deep Convolutional Generative Adversarial Networks on CelebA Dataset using PyTorch C++ API

It’s been around 5 months since I released my last blog on DCGAN Review and Implementation using PyTorch C++ API and I’ve missed writing blogs badly! Straight the to the point, I’m back! But before we start, the PyTorch C++ Frontend has gone through several changes and thanks to the awesome contributors around the world, it resembles the Python API more than it ever did! Since a lot of things have changed, I have also updated my previous blogs (tested on 1.4 Stable build). ...

February 23, 2020 · 3 min · Kushashwa Ravi Shrimali

Deep Convolutional Generative Adversarial Networks: Review and Implementation using PyTorch C++ API

I’m pleased to start a series of blogs on GANs and their implementation with PyTorch C++ API. We’ll be starting with one of the initial GANs - DCGANs (Deep Convolutional Generative Adversarial Networks). The authors (Soumith Chintala, Radford and Luke Metz) in this Seminal Paper on DCGANs introduced DCGANs to the world like this: We introduce a class of CNNs called deep convolutional generative adversarial networks (DCGANs), that have certain architectural constraints, and demonstrate that they are a strong candidate for unsupervised learning. Training on various image datasets, we show convincing evidence that our deep convolutional adversarial pair learns a hierarchy of representations from object parts to scenes in both the generator and discriminator. Additionally, we use the learned features for novel tasks - demonstrating their applicability as general image representations. ...

September 15, 2019 · 10 min · Kushashwa Ravi Shrimali

Setting up Jupyter Notebook (Xeus Cling) for Libtorch and OpenCV Libraries

Introduction to Xeus Cling Today, we are going to run our C++ codes in the Jupyter Notebook. Sounds ambitious? Not much. Let’s see how we do it using Xeus Cling. I’ll quote the definition of Xeus Cling on the official documentation website. xeus-cling is a Jupyter kernel for C++ based on the C++ interpreter cling and the native implementation of the Jupyter protocol xeus. Just like we use Python Kernel in the Jupyter Notebook, we can also use a C++ based interpreter cling combined with a Jupyter protocol called Xeus to reach closer to implementing C++ code in the notebook. ...

August 28, 2019 · 7 min · Kushashwa Ravi Shrimali