A Bernoulli random variable takes 1 with probability p and 0 with probability 1-p. The distribution can be written as:
While understanding the principals of reinforcement learning is easy, making the implementation work is not that easy. These are the major difficulty one may face while implementing RL based algorithm for doing something useful(other that playing an atari game).
- Lack of framework that could have made the implementation easy: Recently introduced "Dopamine" is at its nascent stage. It does not allow creation of customized environment. Basically, it is just for replicating benchmarks based on board-based games.
- Lack of implementation information: Internet is scattered of tutorials and code demostrating how to construct an RL agent that plays a "Pole" game. They just demostrate the agent type, but not necessarily describe the nitty-gritty of theory mapped to implementation.
- So many independent tunables: Once implemented, it is very very hard to tell if the implementation is working correctly.
So, there are some guidlines one can follow to be a little bit confident a
Single instance designs are design that can be used only once. Multi-instance designs are designs that can be used multiple times. In C, multi-instance design can be implemented by structs and passing the address everytime of the structure. However, C++ simplifies this process with class. At compiler level, even the C++ class codes gets converted to something that represents how multi-class instance design is implemented in C.
Below code shows how C implements multi-instance design and how it is done by C++. Also, the efficiency of C++ is equivalent to C, which can be easily demostrated with the compiler generated code.
In the below code, it has been shown that the templates on a class or a function does not c create any overhead, but instead they makes the code even faster by compiling only the relevant parts.
Iterators abstract the complex structures and gives a clean interface to access the data. C++ already provides containers like vector, maps, queues, etc. which implements iterator patterns.
In order to implement a C++ style iterators on a container (class), iterators in the class namespace has to be defined with increment and access functionality overloaded. Below code demostrate this.
Composition is a very important concept in software engineering. Small eleement creates larger and more complex elements. To understand this moe firmly, we can take an example of a case where we need to create GUI elements. Some GPU elements are standlone by itself, but some combines to constructs a bigger GPU elements.
Below code tries to do this.
#include "stdafx.h"
- All instance(non static) data members of Base Class (super class) always becomes part of Derived Class (sub class). This is regardless of what access has been given to the derived class.
- All instance methods of Base class can work for derived class object even constructor or destructor
- When object of the Derived class calls the instance method of derived class or base class, it's address is always passed to it and it gets collected as this pointer.
- When Object of derived class calls instance method of derived class, the object address is passed to the method. And when this method calls the instance method of the base class, the same address is passed to that methods also. Both the method will work on the same object.
- When object of derived class calls instance method of base class, the object address is passed to it. Because of this, when required, the derived function can be called back because we have the derived object pointer.
There are cases where an if-class explosion can happens. Specifically, if explosion happens when there are many if statements to implements and class explosion happens when there are many class that requires those if to be implemented. When these two explodes on their own dimension, the product is called if-class explosion. In order to solve this, bridge pattern are being used. But more importantly, in order to understand that if such a pattern is required, commonality-variability analysis of the given problem must be done.
Consider the below problem, where we do commonality-variability analysis to identify the if-class explosion.
Create a library of UI controls (ListBox, Grid, Button). These should be created as C++ classes. Various application are to be developed using these classes. Each UI class will has to render the respective UI on the screen, once application requires it. This drawing should be performed by directX on Windows, openGL on
In this part, we will learn more about single responsibility priniciple. To learn that, we can start with a problem described below.
Implement a simple concurrent file uploader. Allow the user to keep entering filename, whenever they want to upload. Each filename entered by the user should be uploaded to the FileServer which is remotely located over the internet. Each upload approximately takes 10 seconds time. When the upload for one file is going on, another should not be uploaded. Other files should be uploaded one after the other, the way it happens on google drive client or filezilla.
User should be allowed to enter filenames when upload is going on. No filename entered by the user should be missed. When each upload starts, display the getting uploaded and when upload is completed, dispaly "filename" uploaded.