Binary Step
To make sure that the output is binary, a binary step activation function is used. This is mostly used when you are doing a binary classification. When the input is negative, the activation function outputs 0. And when it is positive, it outputs 1.
PYTHON
1class BinaryStepActivation():
2 def __init__(self, thresh=0):
3 self.thresh = thresh
4
5 def forward(X):
6 out = np.ones_like(X)
7 out[X <= 0] = 0
8 return out