赞
踩
直接上代码
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))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。