-
Notifications
You must be signed in to change notification settings - Fork 1
/
example2.py
43 lines (30 loc) · 1.02 KB
/
example2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'''
Example 2: Deep Neural Network from scrach
@Author _ Nikesh Bajaj
PhD Student at Queen Mary University of London &
University of Genova
Conact _ http://nikeshbajaj.in
n[dot]bajaj@qmul.ac.uk
bajaj[dot]nikkey@gmail.com
'''
import numpy as np
import matplotlib.pyplot as plt
from DeepNet import deepNet
import DataSet as ds
plt.close('all')
dtype = ['MOONS','GAUSSIANS','LINEAR','SINUSOIDAL','SPIRAL']
X, y,_ = ds.create_dataset(200, dtype[3],0.0,varargin = 'PRESET');
Xts, yts,_ = ds.create_dataset(200, dtype[3],0.4,varargin = 'PRESET');
print(X.shape, y.shape)
NN = deepNet(X,y,Xts=Xts, yts=yts, Net = [8,8,5],NetAf =['tanh'], alpha=0.01,miniBatchSize = 0.3, printCostAt =100,AdamOpt=True,lambd=0,keepProb =[1.0])
plt.ion()
for i in range(15):
NN.fit(itr=10)
NN.PlotLCurve()
NN.PlotBoundries(Layers=True)
NN.PlotLCurve()
NN.PlotBoundries(Layers=True)
print(NN)
yi,yp = NN.predict(X)
yti,ytp = NN.predict(Xts)
print('Accuracy::: Training :',100*np.sum(yi==y)/yi.shape[1], ' Testing :',100*np.sum(yti==yts)/yti.shape[1])