Ask Your Question
0

Simple ReLU plot

asked 2024-03-15 06:11:57 +0100

ramesh1600 gravatar image

I am trying to plot this simple ReLU function max(0,x).
But the line is struck at y=0. Can somebody help ?

Here is my code:
plot(max(0,x), -2, 2)

edit retag flag offensive close merge delete

Comments

sage: max_symbolic?

FrédéricC gravatar imageFrédéricC ( 2024-03-15 15:29:30 +0100 )edit

thanks. max_symbolic works.

ramesh1600 gravatar imageramesh1600 ( 2024-03-16 14:11:08 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2024-03-15 16:49:32 +0100

Cyrille gravatar image

updated 2024-03-15 16:50:53 +0100

You can try

   f(x) = max_symbolic(x,0);
   plot(f(x), -2, 2)
edit flag offensive delete link more

Comments

This worked. Thank you very much. I went and read the max_symbolic documentation, I could not understand why max does not work, but the max_symbolic resolved my problem. Is there a simpler explanation for why python max does not work in the plotting ?

ramesh1600 gravatar imageramesh1600 ( 2024-03-16 13:58:40 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-03-15 06:10:57 +0100

Seen: 183 times

Last updated: Mar 15