Photo by Nathan Dumlao on Unsplash

The optimization of any product or service is a key step to ensure the best efficiency possible, which translates into having the most output using the least amount of resources.

Code is versatile, allowing the coder to solve problems in various ways. However, not every way is the most efficient one. To demonstrate it I’ll state a searching problem and use a linear and a binary search algorithm.

Linear search checks for the solution starting at the beginning and moving forward one by one and binary search eliminates half of the searching space everytime it evaluates an object.

After solving…

Organisation. Photo by Jan Antonin Kolar on Unsplash

Keeping your data organised is like keeping a tidy workplace. It is easier to know where things are and frees more space either for storage or for work.

Currently, the database world is divided into SQL database libraries and NoSQL libraries with their own advantages and disadvantages. We’ll be focusing on the SQL counterpart of databases in this story.

We are going to see how to create tables using the SQLite library and how to minimise the insertion of wrong data by providing additional information at the moment of constructing a table and after it is created. …

Constant flow. Photo by Jeremy Bishop on Unsplash

Hands-on Tutorials

The advantage of the Long Short-Term Memory (LSTM) network over other recurrent networks back in 1997 came from an improved method of back propagating the error. Hochreiter and Schmidhuber called it “constant error back propagation” [1].

But what does it mean to be “constant”? We’ll go through the architecture of the LSTM and understand how it forward and back propagates to answer the question. We will make some comparisons to the Recurrent Neural Network (RNN) along the way. If you are not familiar with the RNN, you may want to read about it here.

However, we should first understand what…

Connected. Photo by Sheri Hooley on Unsplash

Let me show you what RNNs are, where they are used, how they forward and backward propagate and how to use them in PyTorch.

Most types of neural networks are built to make predictions on samples whose targets they have been trained on. A prime example is the MNIST dataset. A regular neural network like the MLP knows there are 10 digits and it is only based on them that it makes predictions even if the images are very different from those the network has been trained on.

Now, imagine we could leverage such a network with a sequential analysis by providing a sequence of 9 ordered digits and let the network guess the 10th. …

Choosing the best direction. Photo from

Last time we saw the cost function. It is a quadratic function and this allows us to look for a minimum in which the values obtained for the control input vector will direct the system towards the correct way. Here’s the cost function:

Valley, a minimum path between mountains. Photo by

In this series, we have been learning how to create an MPC. This is a control technology that is more powerfull than the well-known PID but is also more complex and difficult to implement.

To do it we have seen that we need to have a system that we have to be able to model accurately enough. For this project it was chosen a system that heats up a solution using steam that we proceeded to deduce two equations that model the system that you can read about here:

Later we deduced the full State-Space Equation System (SSES) in which…

SpaceX’s self landing rocket. Photo by

Last time we discussed what controllers are and some examples where they are used. We also defined a system to control and deduced two important equations that allow us to model it:

Traffic control. Image via

Have you ever wondered how the cruise control in a car keeps its speed constant? How the pressure of a certain gas in an industrial container is controlled? Or even how your smatphone’s bightness adapts to the room’s light?

The automation of certain dynamic systems require application of control algorithms. A control algorithm is a loop that controls a system by decreasing the error between the desired variable, let’s say pressure inside the container, and a set-point for that same variable. The controller will then calculate a control input variable that changes the system so that the error in the…

Image by

In this publication I will write about the mathmatics behind the simplest 2D Convolutional Neural Network (CNN), I’ll try to make a connection to the Multi Layer Perceptron (MLP) that I wrote about in my last publication. I’ll present a model architecture, forward and back propagation calculations and finally show some other techniques that are widelly used in modern CNNs.

The CNN was implemented as a model that could handle images in a more efficient way than the MLP. Through the usage of kernel masks containing weights, the networks find characteristic patterns in the input images like edges, corners, circles…

Photo by Yurchanka Siarhei, Shutterstock

In the last publication, we talked about the perceptron and the mathmatics behind it. Here, we’ll see how can we extend it to improve its predictive power. To achieve it, we’ll implement what’s called the hidden layer and use a couple of them.

The nodes in the hidden layers capture certain aspects from the inputs or previous activation outputs that converges the possibilities of the prediction. What I mean is, for example, using the mnist dataset, if a certain node in the first hidden layer has an activation output very close to 1, the weights to the next layer may…

Tiago Miguel

Chemical Engineer enthusiast in learning programming with python, data science and machine/deep learning skills

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