Aditya Chatterjee's Blog, page 204

June 8, 2020

An Introduction to BERT

An Introduction to BERT

Reading time: 25 minutes


In Oct 2018 , Google AI released a pre-trained model for performing various Natural language processing tasks .It instantly started getting attention due to the fact that it attains state of art results on most of the NLP tasks . They even claimed that the model has surpassed human level performance which is generally the benchmark for all the Machine learning Algorithms.


You can find the released paper here in which they talked about the process of training the model ...

 •  0 comments  •  flag
Share on Twitter
Published on June 08, 2020 15:03

June 7, 2020

Knuth's optimization in Dynamic Programming

Knuth's optimization is used to optimize the run-time of a subset of Dynamic programming problems from O(N^3) to O(N^2).


Properties of functions

Some properties of two-variable functions required for Kunth's optimzation:


1. Quadrangle inequalities


For a two-variable function $f(x, y)$ :




Convex quandrangle inequality : $\forall_{a \leq b \leq c \leq d}(f(a, c) + f(b, d) \leq f(a, d) + f(b, c))$




Concave quadrangle inequality : $\forall_{a \leq b \leq c \leq d}(f(a, c) + f(b, d) \geq f(a, d) +...

 •  0 comments  •  flag
Share on Twitter
Published on June 07, 2020 16:08

Class based Generic Views in Django

Django is a high-level open-source Python-based Web framework that provides rapid development with pragmatic design. Django often called Batteries-included framework as it provides built-in tools for many functionalities in a web application.


What are views?

Views are just a function that is callable each time a request is made to an application, it takes a request as an argument and returns a response.

Class-Based Generic Views are a superior set of Built-in views that are used for the impleme...

 •  0 comments  •  flag
Share on Twitter
Published on June 07, 2020 13:20

Tim Sort

Reading time: 30 minutes | Coding time: 15 minutes


Tim Sort is a hybrid stable sorting algorithm that takes advantage of common patterns in data, and utilizes a combination of an improved Merge sort and Binary Insertion sort along with some internal logic to optimize the manipulation of large scale real-world data. Tim Sort was first implemented in 2002 by Tim Peters for use in Python.


Operation

Tim sort uses Binary insertion sort and improved merge sort by using galloping in a combination. Bi...

 •  0 comments  •  flag
Share on Twitter
Published on June 07, 2020 12:39

Overview of Maximum Flow Problem

Flow networks are fundamentally directed graphs, where edge has a flow capacity consisting of a source vertex and a sink vertex. The aim of the max flow problem is to calculate the maximum amount of flow that can reach the sink vertex from the source vertex keeping the flow capacities of edges in consideration. The flow at each vertex follows the law of conservation, that is, the amount of flow entering the vertex is equal to the amount of flow leaving the vertex, except for the source and the ...

 •  0 comments  •  flag
Share on Twitter
Published on June 07, 2020 10:36

June 6, 2020

Creating JWT Authentication in REST API in Flask

JSON Web Token is a string which is sent in HTTP request from the browser to the server to validate authenticity of the client. The browser stores the JWT and includes the token with every request in the header.

Now we will create app.py file.


app.py


#import necessary library
from flask import Flask, request
from flask_restful import Resource, Api, reqparse
from security import authenticate, identity
from flask_jwt import JWT, jwt_required, current_identity

#configuring your application
app = ...
 •  0 comments  •  flag
Share on Twitter
Published on June 06, 2020 16:31

Algorithm to find the maximum power of N that divides M factorial (M!)

Reading time: 40 minutes | Coding time: 10 minutes


We are given two numbers M and N. Our aim is to find the highest power of N that divides Factorial of M (M!). We often come across such problems in competitive programming where we require an optimal solution.


First we will discuss about the Brute Force approach and then we will be discussing this problem using Legendre’s formula.


Underlying are some examples which would help in better understanding of the problem.


EXAMPLES


Input : M = 5, N = ...

 •  0 comments  •  flag
Share on Twitter
Published on June 06, 2020 05:28

Adversarial Machine Learning

Adversarial Machine learning is the technique which involves applying different methods in order to construct or generate examples that are meant to fool the machine learning model. These types of examples are called adversarial examples.


In this article, we will explore how an adversary can exploit the machine learning model i.e. methods to generate adversarial examples and we will also talk about some defense strategies against these adversarial examples.


What is an adversarial example?

An ad...

 •  0 comments  •  flag
Share on Twitter
Published on June 06, 2020 04:06

June 4, 2020

K means vs K means++

In this article, we have investigated the distinction between K-means and K-means++ algorithms in detail. Both K-means and K-means++ are clustering methods which comes under unsupervised learning. The main difference between the two algorithms lies in:



the selection of the centroids around which the clustering takes place
k means++ removes the drawback of K means which is it is dependent on initialization of centroid

centroids: A centroid is a point which we assume to be the center of the clu...

 •  0 comments  •  flag
Share on Twitter
Published on June 04, 2020 10:37

Viewing the history of git commits (git log)

Reading time: 30 minutes | Coding time: 10 minutes


Follow a few steps to get along with this tutorial:



Create a directory named git_view_history. Create a python file named hello.py.
Initialize git in this repository. Using command git init.
I have created 3 commits in the repository and it looks as follows:

commit 1:



git commit -m "first commit"

[master (root-commit) 981d5a8] first commit

1 file changed, 1 insertion( )

create mode 100644 hello.py



in this commit, the code simply prints hel...

 •  0 comments  •  flag
Share on Twitter
Published on June 04, 2020 05:49