In [ ]:
import matplotlib as mpl
mpl.use('Agg')
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
import seaborn as sns
import sys
In [ ]:
sys.path.append('../code')
In [ ]:
from NeuralNet import NeuralNet
from TransferFunctions import TanhTF, LinearTF
In [ ]:
from sklearn.datasets import make_classification
X, y = make_classification(n_samples=200, n_features=10,
n_informative=10, n_redundant=0, n_repeated=0,
n_classes=2, n_clusters_per_class=1,
weights=None, flip_y=0.0001, class_sep=1.0,
hypercube=True, shift=0.0, scale=1.0,
shuffle=True, random_state=None)
X=X.T
print('shape of X: {}. (Columns are rows; rows are features)'.format(X.shape))
In [ ]:
y.shape
In [ ]:
# columns are data points and rows are features
d, N = np.shape(X)
C = np.unique(y).shape[0]
In [ ]:
n = NeuralNet(X=X, y=y, hidden_nodes=20,
hiddenTF=TanhTF, outputTF=TanhTF,
minibatch_size=4,
eta0 = 0.001,
verbose=True)
In [ ]:
n.run(epochs=20)
In [ ]:
n.results.tail()
In [ ]:
sl = n.plot_square_loss()
In [ ]:
l01 = n.plot_01_loss()
In [ ]:
p = n.plot_weight_evolution()
In [ ]:
p1 = n.plot_sum_of_weights('W1')
p2 = n.plot_sum_of_weights('W2')
In [ ]:
p1 = n.plot_norm_of_gradient('W1')
p2 = n.plot_norm_of_gradient('W2')
In [ ]:
n.results.tail(1).T
In [ ]: