mirror of
https://github.com/autistic-symposium/tensorflow-for-deep-learning-py.git
synced 2025-05-10 10:45:04 -04:00
Add numpy nn example
This commit is contained in:
parent
305e85e8b7
commit
e1c2e8dd5e
2 changed files with 308 additions and 24 deletions
25
Numpy/nn_case_study.py
Normal file
25
Numpy/nn_case_study.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python
|
||||
# Adapted from: http://cs231n.github.io/neural-networks-case-study/
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
N = 100 # number of points per class
|
||||
D = 2 # dimensionality
|
||||
K = 3 # number of classes
|
||||
|
||||
# data matrix (each row = single example)
|
||||
X = np.zeros((N*K, D))
|
||||
# class labels
|
||||
y = np.zeros(N*K, dtype='uint8')
|
||||
|
||||
for j in range(K):
|
||||
ix = range(N*j,N*(j+1))
|
||||
r = np.linspace(0.0,1,N) # radius
|
||||
t = np.linspace(j*4,(j+1)*4,N) + np.random.randn(N)*0.2 # theta
|
||||
X[ix] = np.c_[r*np.sin(t), r*np.cos(t)]
|
||||
y[ix] = j
|
||||
|
||||
|
||||
# visualize the data:
|
||||
plt.scatter(X[:, 0], X[:, 1], c=y, s=40, cmap=plt.cm.Spectral)
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue