TFLearn And Its Installation in Tensorflow
TFLearn can be described as a transparent and modular deep learning library created on top of the Tensorflow framework. The prime objective of TFLearn is to provide a higher-level API to Tensorflow so as to facilitate and accelerate experimentation, yet remaining fully compatible and transparent with it.
- TFLearn is easy to understand and is a user-friendly high-level API for building deep neural networks structure.
- Through built-in high compatibility of neural network layers, optimizers, regularizers, metrics, etc. it performs fast prototyping.
- TFLearn functions can be used independently as well since all functions are built upon tensors.
- With the use of powerful helper functions, any TensorFlow graph can be trained easily that accepts multiple inputs, outputs, and optimizers, etc.
- TFLearn can also be used to create magnificent graph visualizations with details about gradients, weights, activations, etc. effortlessly.
- Easy device placement for utilizing multiple CPU/GPU.
Many recent popular deep learning network architectures such as Convolutions, Residual networks, LSTM, PReLU, BatchNorm, Generative Networks, etc are supported by this high-level API.
Note: TFLearn v0.5 is only compatible with TensorFlow version 2.x
Install TFLearn by executing this command:
For stable version:
pip install tflearn
For state-of-art version:
pip install git+https://github.com/tflearn/tflearn.git
Example of tflearn:
Through the example given below application of TFLearn Regression is demonstrated.
In order to implement a classifier using tflearn, the first step is to import tflearn library and sub-modules like conv (for convolution layers), core (for dropout and fully connected layer), estimator (to apply linear or logistic regression), and datasets (to access datasets like MNIST, CIFAR10, etc.)
Using load_data, the MNIST dataset is extracted and divided into training and validation set with input x having a shape (samples,784). Now in order to use input x for training we reshape it from (samples,784) to (samples, 28,28,1) using .reshape(NewShape). After this, we define the same new shape for the network. Now for defining the network model we stack a few convolution2d layers and max_pooling2d layers together followed by stacked dropout and fully connected layers.