Types of machine learning

If we consider the kind of signal or feedback available to a learning system, then machine learning falls into three categories:

  • supervised learning: uses labelled data for training, meaning each piece of data includes both a feature vector x and the desired output y;
  • unsupervised learning: uses unlabelled data X for training the model;
  • reinforcement learning: the learning system is given a goal and interacts with a dynamic environment.

If instead we consider the desired output of a machine learning system, then we get these categories:

  • classification (inputs are assigned to a class, out of a set of predetermined classes)
  • regression (inputs are assigned a value from a continuous range)
  • clustering (inputs are divided into a series of groups or classes, which are not known beforehand)
  • density estimation
  • dimensionality reduction.

 

Posted in Machine learning | Leave a comment

Setting up Tensorflow in Windows 10

The Tensor Flow library has only recently been adapted to run on Windows, without requiring a Docker container, and the installation is still a little tricky.

First of all, install Anaconda on your Windows 10 machine. Get the Python 3.6 version.

Next, in a command window, run the following script:

conda create –name tensorflow python=3.5
activate tensorflow
conda install jupyter
conda install scipy
pip install tensorflow

To test the TensorFlow installation, run this script, inside the environment you created:

python

>>> import tensorflow as tf
>>> hello = tf.constant(‘Hello, TensorFlow!’)
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>>

To run TensorFlow in a Jupyter Notebook, open a new command window, activate the virtual environment, and then switch on the Jupyter server inside it:

activate tensorflow

jupyter notebook

which will open a browser window with the Jupyter menu. Select from the drop-down at the top right of the page:

New > Python 3

which will create a new Jupyter notebook in another browser tab, running in the tensorflow virtual environment. Now you can write the entire test script again in a cell:

import tensorflow as tf

hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))

and select

Cell > Run All

to make sure it works.

img2

Tensorflow-GPU

You can install the tensorflow-gpu package instead, the advantage being much higher performance. In that case, you have to download and install the Cuda Toolkit as a prerequisite. The procedure is identical to the one described above, except that when you get to the line:

pip install tensorflow

you should do this instead:

pip install tensorflow-gpu

Note that I tried this approach, but it did not work, possibly because of my laptop’s hardware configuration. But feel free to try it yourself. If it does not work, just delete the virtual environment you created and start over.

Posted in Anaconda, Jupyter, Machine learning, Tensorflow | Leave a comment