ReLU激活函数也叫线性整流函数,ReLU是Rectified Linear Unit(ReLU)的简拼。
import numpy as np
import matplotlib.pyplot as plot
def relu(x):
return np.maximum(0, x)
if __name__ == "__main__":
a = np.arange(-20, 20, 0.1)
b = relu(a)
plot.plot(a, b, label="ReLU", color="red")
plot.legend()
plot.grid()
plot.show()
如图: