#  You will be working with a dataset that contains handwritten digits.
#

# Load Training Data
print 'Loading and Visualizing Data ...'

data = scipy.io.loadmat('ex4/ex4data1.mat')
X = data['X']
y = data['y']
m, _ = X.shape

# Randomly select 100 data points to display
rand_indices = np.random.permutation(range(m))
sel = X[rand_indices[0:100], :]

displayData(sel)

#raw_input("Program paused. Press Enter to continue...")


## ================ Part 2: Loading Parameters ================
# In this part of the exercise, we load some pre-initialized 
# neural network parameters.

print 'Loading Saved Neural Network Parameters ...'

# Load the weights into variables Theta1 and Theta2
data = scipy.io.loadmat('ex4/ex4weights.mat')
Theta1 = data['Theta1']
Theta2 = data['Theta2']
y = np.squeeze(y)
Example #2
0
show()
input('Program paused. Press Enter to continue...')

## =============== Part 4: Loading and Visualizing Face Data =============
#  We start the exercise by first loading and visualizing the dataset.
#  The following code will load the dataset into your environment
#
print('Loading face dataset.')

#  Load Face dataset
data = scipy.io.loadmat('ex7faces.mat')
X = data['X']

#  Display the first 100 faces in the dataset
displayData(X[0:100, :])

input('Program paused. Press Enter to continue...')

## =========== Part 5: PCA on Face Data: Eigenfaces  ===================
#  Run PCA and visualize the eigenvectors which are in this case eigenfaces
#  We display the first 36 eigenfaces.
#
print(
    'Running PCA on face dataset.\n(this might take a minute or two ...)\n\n')

#  Before running PCA, it is important to first normalize X by subtracting
#  the mean value from each feature
X_norm, mu, sigma = featureNormalize(X)

#  Run PCA
#show()
#raw_input('Program paused. Press Enter to continue...')  

## =============== Part 4: Loading and Visualizing Face Data =============
#  We start the exercise by first loading and visualizing the dataset.
#  The following code will load the dataset into your environment
#
print 'Loading face dataset.'

#  Load Face dataset
data = scipy.io.loadmat('ex7/ex7faces.mat')
X = data['X']

#  Display the first 100 faces in the dataset
displayData(X[0:100, :])

#raw_input('Program paused. Press Enter to continue...')  

## =========== Part 5: PCA on Face Data: Eigenfaces  ===================
#  Run PCA and visualize the eigenvectors which are in this case eigenfaces
#  We display the first 36 eigenfaces.
#
print 'Running PCA on face dataset.\n(this might take a minute or two ...)\n\n'

#  Before running PCA, it is important to first normalize X by subtracting 
#  the mean value from each feature
X_norm, mu, sigma = featureNormalize(X)

#  Run PCA
U, S, V = pca(X_norm)
Example #4
0
#  You will be working with a dataset that contains handwritten digits.
#

# Load Training Data
print('Loading and Visualizing Data ...')

data = scipy.io.loadmat('ex4data1.mat')
X = data['X']
y = data['y']
m, _ = X.shape

# Randomly select 100 data points to display
rand_indices = np.random.permutation(range(m))
sel = X[rand_indices[0:100], :]

displayData(sel)

input("Program paused. Press Enter to continue...")

## ================ Part 2: Loading Parameters ================
# In this part of the exercise, we load some pre-initialized
# neural network parameters.

print('Loading Saved Neural Network Parameters ...')

# Load the weights into variables Theta1 and Theta2
data = scipy.io.loadmat('ex4weights.mat')
Theta1 = data['Theta1']
Theta2 = data['Theta2']
y = np.squeeze(y)
Example #5
0
#  We start the exercise by first loading and visualizing the dataset.
#  You will be working with a dataset that contains handwritten digits.

# Load Training Data
print('Loading and Visualizing Data ...')

data = scipy.io.loadmat('ex4data1.mat')
X = data['X']
y = data['y'].flatten()
m = np.size(X, 0)

# Randomly select 100 data points to display
sel = np.random.permutation(range(m))
sel = sel[:100]

displayData(X[sel])

input('Program paused. Press Enter to continue.')

# ================ Part 2: Loading Parameters ================
# In this part of the exercise, we load some pre-initialized
# neural network parameters.

print('\nLoading Saved Neural Network Parameters ...')

# Load the weights into variables Theta1 and Theta2
weights = scipy.io.loadmat('ex4weights.mat')
Theta1 = weights['Theta1']
Theta2 = weights['Theta2']

# Unroll parameters