Make your own machine learning library.

Photo by Mathew Schwartz on Unsplash

In this post we will go through the mathematics of machine learning and code from scratch, in Python, a small library to build neural networks with a variety of layers (Fully Connected, Convolutional, etc.). Eventually, we will be able to create networks in a modular fashion:


In this article we will see how to use the finite difference method to solve non-linear differential equations numerically. We will practice on the pendulum equation, taking air resistance into account, and solve it in Python.

We will find the differential equation of the pendulum starting from scratch, and then solve it. Before we start, we need a little background on Polar coordinates.

Polar Coordinates

You already know the famous Cartesian coordinates, which are probably the most used in everyday life. However, in some cases, describing the position of an object in Cartesian coordinates isn’t practical. …


Create a computer-generated image using the Ray Tracing algorithm coded from scratch in Python.

fig. 1 — computer-generated image

In this post I will give you a glimpse of what computer graphics algorithms may look like. I will explain the ray tracing algorithm and show a simple implementation in Python.

By the end of this article you’ll be able to make a program that will generate the above image, without making use of any fancy graphic library! Only NumPy. Isn’t it crazy?! Let’s dive in!

P.S. This article is by no mean a complete guide / explanation of ray tracing, since this is such a vast subject, but rather an introduction for curious people :)

Prerequisites

We only need very…


Create smooth shapes using Bézier curves.

In this article, we will see how we can use cubic Bézier curves to create a smooth line that goes through a predefined set of points. If you don’t know what Bézier curves are, you might want to check out this post I have written which could do as an introduction, or simply browse Wikipedia!

Cubic Bézier Curves

The goal is to fit n+1 given points (P0, …, Pn). In order to fit these points, we are going to use one cubic Bézier curve (4 control points) between each consecutive pair of points.


Understand the mathematics of Bézier curves

Bézier curves are used a lot in computer graphics, often to produce smooth curves, and yet they are a very simple tool. If you have ever used Photoshop you might have stumbled upon that tool called “Anchor” where you can put anchor points and draw some curves with them… Yep, these are Bézier curves. Or if you have used vector-based graphic, SVG, these too use Bézier curves. Let’s see how it works.

Definition

Given n+1 points (P0, …, Pn) called the control points, the Bézier curve defined by these points is defined as:


What does it take ?

Photo by Kid Circus on Unsplash

I took an “entrepreneurial” course this year at my University.

I’ve heard about the top 10 techniques that every entrepreneur must know. I’ve heard about how I should talk to an audience to convince them. I’ve heard about the relentless mindset I should have, and never fear failure. I’ve heard about how I should have diversified skills among my team. I’ve heard about how important networking is. I’ve heard about the fall and the rise of dozens of people I don’t even know. I’ve heard about all the mistakes I should avoid, and everything I should do in order to…


In this post, we will see several basic optimization algorithms that you can use in various data science problems.

Many algorithms used in Machine Learning are based on basic mathematical optimization methods. Discovering these algorithms directly in the context of Machine Learning might be confusing because of all the prerequisites. Thus, I think it might be a good idea to see these algorithms free of any context in order to get a better understanding of these techniques.

Descent Algorithms

Descent algorithms are meant to minimise a given function, that’s it. Really. These algorithms proceed iteratively, it means that they successively improve their current solution. You might think:

What if I want to find the maximum of a function ?

Simply, add…


Photo by Mathew Schwartz on Unsplash

Cet article est une traduction du poste originalement publié ici.

Le but de cet article est de comprendre comment est implémenté un framework tel que Keras, mais également de comprendre les fondements mathématiques qui se cachent derrière le machine learning. Nous allons donc créer en partant de zéro, une mini bibliothèque qui nous permettra de construire des réseaux de neurones très facilement, comme ci dessous:


If you’re reading this at the time it is published then happy new year to you ! 🎉🥂 I thought I would publish something a bit different from the usual stuff, so let’s talk about happiness :)

Last year, I stumbled upon an old Instagram story from Will Smith where he talks about happiness. He said that your happiness is your responsibility. I found this idea interesting and I started thinking about it.

Photo by Rob Schreckhise on Unsplash

Your Happiness

Regardless of the time or place you live in, regardless of your gender, regardless of your age, your religion, and beliefs, no matter who you are, the…


Understand where the Bellman equation comes from

Photo by Brett Jordan on Unsplash

Q-Learning

Q-Learning is a type of Reinforcement Learning which is a type of Machine Learning. Reinforcement learning has been used lately (typically) to teach an AI to play a game (Google DeepMind Atari, etc). Our goal is to understand a simple version of Reinforcement learning called Q-Learning, and write a program that will learn how to play a simple “game”. Let’s dive in!

Markov Chain

A Markov chain is a mathematical model that experiences transition of states with probabilistic rules.

Omar Aflak

Programming & Mathematics.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store