https://github.com/star2dust/numpy-notes
A tutorial to learn numpy and matplotlib.
https://github.com/star2dust/numpy-notes
matplotlib numpy tutorial
Last synced: 12 months ago
JSON representation
A tutorial to learn numpy and matplotlib.
- Host: GitHub
- URL: https://github.com/star2dust/numpy-notes
- Owner: star2dust
- License: mit
- Created: 2020-06-26T09:48:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-27T02:27:41.000Z (over 5 years ago)
- Last Synced: 2025-01-01T19:29:01.128Z (about 1 year ago)
- Topics: matplotlib, numpy, tutorial
- Language: HTML
- Homepage: https://star2dust.github.io/numpy-notes/
- Size: 647 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Numpy and Matplotlib
## Install Requirements
```shell
pip install numpy
pip install matplotlib
```
## Tutorials
See [star2dust.github.io/numpy-notes/](https://star2dust.github.io/numpy-notes/). (Chinese)
## Examples
- Calculate `relu` and `sigmoid` function.
```python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
# fig size
plt.figure(figsize=(8, 3))
# from -10.0 to 10.0 with interval = 0.1
x = np.arange(-10, 10, 0.1)
# calculate Sigmoid function
s = 1.0 / (1 + np.exp(- x))
# calculate ReLU function
y = np.clip(x, a_min = 0., a_max = None)
#########################################################
# plot
# two subfigures, Sigmoid in the left
f = plt.subplot(121)
# plot curve
plt.plot(x, s, color='r')
# add text
plt.text(-5., 0.9, r'$y=\sigma(x)$', fontsize=13)
# set x and y axis
currentAxis=plt.gca()
currentAxis.xaxis.set_label_text('x', fontsize=15)
currentAxis.yaxis.set_label_text('y', fontsize=15)
# ReLU in the right
f = plt.subplot(122)
# plot curve
plt.plot(x, y, color='g')
# add text
plt.text(-3.0, 9, r'$y=ReLU(x)$', fontsize=13)
# set x and y axis
currentAxis=plt.gca()
currentAxis.xaxis.set_label_text('x', fontsize=15)
currentAxis.yaxis.set_label_text('y', fontsize=15)
plt.show()
```
