OpenCV installation in virtualenv

This post introduces how to install openCV in virtualenv on Ubuntu 16.04.

Make sure Python and Virtualenv is installed on your Ubuntu first.

Check my post about more details about how to setup python virtual environment and why it is better to install python libraries in Python virtual environment.

  • Install OpenCV inside a virutalenv

activate your virtualenv first, then

if you only  need main modules, run the following commands

$ pip3 install opencv-python

if you need both main and contrib modules (check extra modules listing from OpenCV documentation), run the following commands:

$ pip3 install opencv-contrib-python
  • If you want to install OpenCV on your machine system-wide,

use the following instructions.

$ sudo apt-get install libopencv-dev python-opencv

# if you only  need main modules, run
$ sudo pip3 install opencv-python

# if you need both main and contrib modules (check extra modules listing from OpenCV documentation), run
$ sudo pip3 install opencv-contrib-python

References:

Opencv-python project description (PDF)

Model-free vs. Model-based Methods

As Kahneman (2011) pointed out in his book “Thinking, fast and slow’’, we have two modes of thinking: fast and slow. For example, we do not need to think much about how to walk, how to eat; but we do need to think slowly for some complex tasks such as planing our travel routes.

In reinforcement learning, there are two main categories of methods: model-free and model based.

  • Model-free methods: never learn task T and environment E  explicitly. At the end of learning, agent knows how to act, but doesn’t explicitly know anything about the environment. Deep learning algorithms are model-free methods.
  • Model-based methods: explicitly learn task T. (see model-based reasoning to get a sense of it.)

AlphaGo involves both model-free methods (Convolutional Neural Network (CNN)), and also model-based methods (Monte Carlo Tree Search (MCTS)). In fact, AlphaGo is pretty similar to how we humans think: involving both fast intuition (i.e., cost function by CNN) and also careful and slow thinking (i.e., MCTS).

Combining model-free and model-based methods should probably be the way to go for the solutions to many real-world problems (fast intuition + careful planing).

 

References:

Kahneman, Daniel. Thinking, fast and slow. Macmillan, 2011.