MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# What is the use of activation functions in keras ?

This recipe explains what is the use of activation functions in keras

Activation Functions in Keras

An activation function is a mathematical **gate** in between the input feeding the current neuron and its output going to the next layer. It can be as simple as a step function that turns the neuron output on and off, depending on a rule or threshold. Or it can be a transformation that maps the input signals into output signals that are needed for the neural network to function.

3 Types of Activation Functions 1. Binary Step Function 2. Linear Activation Function 3. Non-Linear Activation Functions

Activation Functions futher divided into sub parts that we are familiar with. 1. Sigmoid / Logistic 2. TanH / Hyperbolic Tangent 3. ReLU (Rectified Linear Unit) 4. Leaky ReLU 5. Parametric ReLU 6. Softmax 7. Swish 8. Softplus

```
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras import activations
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from tensorflow.keras import layers
```

Defining the model and then define the layers, kernel initializer, and its input nodes shape.

```
#Model
model = Sequential()
model.add(layers.Dense(64, kernel_initializer='uniform', input_shape=(10,)))
```

We will show you how to use activation functions on some models to works

```
a = tf.constant([-200, -10, 0.0, 10, 200], dtype = tf.float32)
b= tf.keras.activations.relu(a).numpy()
print(b)
```

[ 0. 0. 0. 10. 200.]

```
a = tf.constant([-200, -10.0, 0.0, 10.0, 200], dtype = tf.float32)
b = tf.keras.activations.sigmoid(a).numpy()
b
```

array([0.000000e+00, 4.539993e-05, 5.000000e-01, 9.999546e-01, 1.000000e+00], dtype=float32)

```
a = tf.constant([-200, -10.0, 0.0, 10.0, 200], dtype = tf.float32)
b = tf.keras.activations.softplus(a)
b.numpy()
```

array([0.0000000e+00, 4.5398901e-05, 6.9314718e-01, 1.0000046e+01, 2.0000000e+02], dtype=float32)

```
a = tf.constant([-200.0,-10.0, 0.0,10.0,200.0], dtype = tf.float32)
b = tf.keras.activations.tanh(a)
b.numpy()
```

array([-1., -1., 0., 1., 1.], dtype=float32)

We passed the same input to all the activation functions to get the different outputs. So, we can easily understand and observe the difference between all the activation functions easily.

In this time series project, you will forecast Walmart sales over time using the powerful, fast, and flexible time series forecasting library Greykite that helps automate time series problems.

Use the Adult Income dataset to predict whether income exceeds 50K yr based oncensus data.

In this time series project, you will build a model to predict the stock prices and identify the best time series forecasting model that gives reliable and authentic results for decision making.

In this deep learning project, you will implement one of the most popular state of the art Transformer models, BERT for Multi-Class Text Classification

Want to search images of clothes which have text on them? Then this project talks through how we can classify an image whether it has text on it or not. For this we use state of the model called as inception and try and deepdive into how it works on our dataset

In this supervised learning machine learning project, you will predict the availability of a driver in a specific area by using multi step time series analysis.

The project will use rasa NLU for the Intent classifier, spacy for entity tagging, and mongo dB as the DB. The project will incorporate slot filling and context management and will be supporting the following intent and entities. Intents : product_info | ask_price|cancel_order Entities : product_name|location|order id The project will demonstrate how to generate data on the fly, annotate using framework and how to process those for different pieces of training as discussed above .

Classification ML Project for Beginners - A Hands-On Approach to Implementing Different Types of Classification Algorithms in Machine Learning for Predictive Modelling

Recommender System Machine Learning Project for Beginners - Learn how to design, implement and train a rule-based recommender system in Python

In this NLP Project, you will learn how to use the popular topic modelling library Gensim for implementing two state-of-the-art word embedding methods Word2Vec and FastText models.