Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 67be747

Browse files
committedSep 4, 2024
Plot relu
1 parent 38f1dfa commit 67be747

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎relu_graph.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
(* \text{ReLU}(x) = \max(0, x) *)
3+
4+
relu[x_] := Piecewise[{{x, x >= 0}, {0, x < 0}}]
5+
6+
relu[x_] := Max[0, x]
7+
8+
Plot[relu[x], {x, -10, 10}, PlotRange -> All, AxesLabel -> {"x", "ReLU(x)"}]
9+
10+
(* 3D *)
11+
relu2D[x_, y_] := Max[0, x + y]
12+
13+
Plot3D[relu2D[x, y], {x, -10, 10}, {y, -10, 10},
14+
PlotRange -> All, AxesLabel -> {"x", "y", "ReLU(x+y)"},
15+
ColorFunction -> "Rainbow", Mesh -> None]
16+

‎relu_graph2.png

314 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.