Author: Valerio Maggio
Contacts:
@leriomaggio
|
valeriomaggio
|
valeriomaggio_at_gmail
|
Getting Started
In this blog post, we will dive into the exciting world of Deep Learning using Keras and Tensorflow. We’ll walk you through the necessary steps to set up your environment, install the required packages, and run your first machine learning model.
Table of Contents
- Part I: Introduction
- Part II: Supervised Learning
- Part III: Unsupervised Learning
- Part IV: Recurrent Neural Networks
- Part V: Additional Materials
- Requirements
- Setting the Environment
- Notes about Installing Theano with GPU support
- Installing Tensorflow
- Configure Keras with Tensorflow
- Test if everything is up and running
Part I: Introduction
In this section, we will provide an overview of Artificial Neural Networks, starting from the basic Perceptron model to complex Multi-Layer Perceptron (MLP) models. We will also introduce various deep learning frameworks, with an emphasis on Keras.
Part II: Supervised Learning
Moving ahead, we will discuss fully connected networks and touch upon advanced concepts like Convolutional Neural Networks (CNNs) and how to work with the MNIST dataset.
Part III: Unsupervised Learning
In this part, we’ll explore AutoEncoders, word2vec, and doc2vec embeddings, providing you with the tools to understand unsupervised learning techniques.
Part IV: Recurrent Neural Networks
We will delve into Recurrent Neural Networks (RNNs) and discuss frameworks like SimpleRNN, Long Short-Term Memory (LSTM), and Gated Recurrent Unit (GRU).
Part V: Additional Materials
Lastly, we will highlight some additional materials on custom layers in Keras and multi-modal network topologies.
Requirements
Ensure you have the following packages:
- Python version 3.5 or later (Anaconda recommended)
- NumPy: version 1.10 or later
- SciPy: version 0.16 or later
- Matplotlib: version 1.4 or later
- Pandas: version 0.16 or later
- Scikit-learn: version 0.15 or later
- Keras: version 2.0 or later
- TensorFlow: version 1.0 or later
- IPython/Jupyter version 4.0 or later (optional but recommended)
- NVIDIA cuDNN (for machines with NVIDIA GPUs)
Setting the Environment
This repository provides files to re-create virtual environments using conda for Linux and OSX systems. For instance, on Linux, you can run the following command:
conda env create -f deep-learning.yml
For OSX, just change the filename accordingly.
Notes about Installing Theano with GPU Support
If you encounter errors enabling GPU support for Theano, follow these steps:
- If using Anaconda, execute:
- Install libgpuarray from source by following the guide on libgpuarray installation.
- Then, install pygpu from source:
- Finally, install Theano:
conda install theano pygpu
python setup.py build
python setup.py install
pip install theano
Installing Tensorflow
To install TensorFlow, you have two options, depending on whether you want to use GPU support:
- For CPU only:
pip install tensorflow
pip install tensorflow-gpu
Note: Ensure NVIDIA Drivers and CuDNN are installed and configured prior to this, for which you can refer to the official Tensorflow documentation.
Configure Keras with Tensorflow
By default, Keras is set to use Theano as the backend. To configure it to use TensorFlow, follow these steps:
- Create the `keras.json` file if it does not exist:
- Copy the following content into the file:
- Verify it is properly configured:
touch $HOME/.keras/keras.json
{
"epsilon": 1e-07,
"backend": "tensorflow",
"floatx": "float32",
"image_data_format": "channels_last"
}
cat $HOME/.keras/keras.json
Test if everything is up and running
To confirm your installation worked, check that you can successfully import the necessary libraries:
import numpy as np
import scipy as sp
import pandas as pd
import matplotlib.pyplot as plt
import sklearn
import keras # Using TensorFlow backend.
Then, print the versions of the installed libraries to ensure they meet the requirements.
import numpy
print(numpy: , numpy.__version__)
import scipy
print(scipy: , scipy.__version__)
import matplotlib
print(matplotlib: , matplotlib.__version__)
import sklearn
print(scikit-learn: , sklearn.__version__)
import keras
print(keras: , keras.__version__)
import tensorflow as tf
print(Tensorflow: , tf.__version__)
If everything worked till now, you’re ready to start!
Troubleshooting
In case of issues while installing packages or running your models, consider the following:
- Check if all package versions are compatible with each other.
- Ensure that your GPU drivers are up to date if using GPU support.
- If you still face problems, remember: sometimes starting over with a clean virtual environment can save you a lot of hassle.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.


valeriomaggio_at_gmail