Google Colab - Installing ML Libraries



Colab supports most of machine learning libraries available in the market. In this chapter, let us take a quick overview of how to install these libraries in your Colab notebook.

To install a library, you can use either of these options −

!pip install

or

!apt-get install

Keras

Keras, written in Python, runs on top of TensorFlow, CNTK, or Theano. It enables easy and fast prototyping of neural network applications. It supports both convolutional networks (CNN) and recurrent networks, and also their combinations. It seamlessly supports GPU.

To install Keras, use the following command −

!pip install -q keras

PyTorch

PyTorch is ideal for developing deep learning applications. It is an optimized tensor library and is GPU enabled. To install PyTorch, use the following command −

!pip3 install torch torchvision

MxNet

Apache MxNet is another flexible and efficient library for deep learning. To install MxNet execute the following commands −

!apt install libnvrtc8.0
!pip install mxnet-cu80

OpenCV

OpenCV is an open source computer vision library for developing machine learning applications. It has more than 2500 optimized algorithms which support several applications such as recognizing faces, identifying objects, tracking moving objects, stitching images, and so on. Giants like Google, Yahoo, Microsoft, Intel, IBM, Sony, Honda, Toyota use this library. This is highly suited for developing real-time vision applications.

To install OpenCV use the following command −

!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python

XGBoost

XGBoost is a distributed gradient boosting library that runs on major distributed environments such as Hadoop. It is highly efficient, flexible and portable. It implements ML algorithms under the Gradient Boosting framework.

To install XGBoost, use the following command −

!pip install -q xgboost==0.4a30

GraphViz

Graphviz is an open source software for graph visualizations. It is used for visualization in networking, bioinformatics, database design, and for that matter in many domains where a visual interface of the data is desired.

To install GraphViz, use the following command −

!apt-get -qq install -y graphviz && pip install -q pydot

By this time, you have learned to create Jupyter notebooks containing popular machine learning libraries. You are now ready to develop your machine learning models. This requires high processing power. Colab provides free GPU for your notebooks.

In the next chapter, we will learn how to enable GPU for your notebook.

Advertisements