直接上代码
import torch
import matplotlib.pyplot as plt
A = torch.arange(-10, 10, 1, dtype=torch.float(32))
def relu(x):
return torch.maximum(torch.tensor(0), x)
plt.plot(relu(A))
结果如下:
import torch
import matplotlib.pyplot as plt
A = torch.arange(-10, 10, 1, dtype=torch.float(32))
def sigmoid(x):
return 1 / (1 + torch.exp(-x))
plt.plot(sigmoid(A))