def run(): input_layer_size = 400 hidden_layer_size = 25 num_labels = 10 print('Loading and Visualizing Data...') X, y = digit_data['X'], digit_data['y'] m = X.shape[0] # Randomly select 100 data points to display sel = sp.random.permutation(m) multiclass.displayData(X[sel, :]) print('Program paused. Press enter to continue.') raw_input() Theta1, Theta2 = weights_data['Theta1'], weights_data['Theta2'] neurnet.predict(Theta1, Theta2, X) print('Program paused. Press enter to continue.') raw_input() rp = sp.random.permutation(m) for i in range(0, m): pred = neurnet.predict(Theta1, Theta2, sp.asmatrix(X[rp[i], :])) print("Neural Network Prediction: %d (digit %d)\n" % (pred[0], sp.mod(pred[0], 10)))
def run(): X, y = digit_data['X'], digit_data['y'] m = X.shape[0] rand_indices = sp.random.permutation(m) multiclass.displayData(X) print('Program paused. Press enter to continue.') raw_input() print('Training One-vs-All Logistic Regression...') lamda = 0.1 num_labels = 10 all_theta = multiclass.oneVsAll(X, y, num_labels, lamda) print('Program paused. Press enter to continue.') raw_input() print all_theta.shape multiclass.predict(all_theta, X, y)