LoginSignup
1
2

More than 3 years have passed since last update.

matplotlibで簡単にグラフを書く

Last updated at Posted at 2020-07-19

あれ、あのグラフってどんな感じだったっけ?というときにさらっと書いて確認したい(のでWarningとかが出ても気にしない)。

Log

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0, 10, 0.01)
y = np.log(x)

plt.grid()
plt.plot(x,y)
plt.show()

image.png

Sigmoid

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(-10, 10, 0.01)
y = 1 / (1 + np.exp(-x))

plt.grid()
plt.plot(x,y)
plt.show()

image.png

tanh

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(-10, 10, 0.01)
y = (np.exp(x)-np.exp(-x))/(np.exp(x)+np.exp(-x))

plt.grid()
plt.plot(x,y)
plt.show()

image.png

Relu

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(-10, 10, 0.01)
y = np.maximum(0, x)

plt.grid()
plt.plot(x,y)
plt.show()

image.png

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2