File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 33My Youtube Channel: https://www.youtube.com/user/MorvanZhou
44
55Dependencies:
6- torch: 0.1.11
6+ torch: 0.4
77matplotlib
88"""
99import torch
1717x_np = x .data .numpy () # numpy array for plotting
1818
1919# following are popular activation functions
20- y_relu = F .relu (x ).data .numpy ()
21- y_sigmoid = F .sigmoid (x ).data .numpy ()
22- y_tanh = F .tanh (x ).data .numpy ()
23- y_softplus = F .softplus (x ).data .numpy ()
24- # y_softmax = F.softmax(x) softmax is a special kind of activation function, it is about probability
25-
20+ y_relu = torch .relu (x ).data .numpy ()
21+ y_sigmoid = torch .sigmoid (x ).data .numpy ()
22+ y_tanh = torch .tanh (x ).data .numpy ()
23+ y_softplus = F .softplus (x ).data .numpy () # there's no softplus in torch
24+ # y_softmax = torch.softmax(x, dim=0).data.numpy() softmax is a special kind of activation function, it is about probability
2625
2726# plt to visualize these activation function
2827plt .figure (1 , figsize = (8 , 6 ))
4645plt .ylim ((- 0.2 , 6 ))
4746plt .legend (loc = 'best' )
4847
49- plt .show ()
48+ plt .show ()
You can’t perform that action at this time.
0 commit comments