Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| typedef struct vector { | |
| int xhat; | |
| int yhat; | |
| int zhat; | |
| } vector; | |
| vector* scalar(int s, vector* S); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cnt = 0 | |
| print(f'Number of test samples is: {num-size}') | |
| for i in range(num-size): | |
| t = y_test[i].reshape(output_layer,1) | |
| # set nodes | |
| x0 = X_test[i].reshape(input_layer,1) | |
| x1 = sigmoid(w1.dot(x0)+b1) | |
| x2 = sigmoid(w2.dot(x1)+b2) | |
| cnt += np.argmax(x2) == np.argmax(t) | |
| print(f'Testing accuracy is {100 * cnt/(num-size):.2f}%') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lr = .001 | |
| epochs = [x for x in range(50)] | |
| Error = 0 | |
| for epoch in epochs: | |
| error = 0 | |
| cnt = 0 | |
| for i in range(size): | |
| # get the true value | |
| t = y_train[i].reshape(output_layer,1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input_layer = 784 | |
| hidden_layer = 64 | |
| output_layer = 10 | |
| w1 = np.random.normal(0, | |
| 1/np.sqrt(input_layer), | |
| size = (hidden_layer,input_layer)) | |
| w2 = np.random.normal(0, | |
| 1/np.sqrt(hidden_layer), | |
| size = (output_layer,hidden_layer)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mnist = fetch_openml('mnist_784', version=1, cache=True) | |
| list(mnist) | |
| mnist.data.shape | |
| mnist.target.shape | |
| plt.imshow(mnist.data[100].reshape(28,28),cmap='gray') | |
| images = (0.99 * mnist.data + 0.01)/ 255 | |
| def sigmoid(x): | |
| return 1/(1+np.exp(-x)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from sklearn.datasets import fetch_openml | |
| from sklearn.model_selection import train_test_split | |
| import matplotlib.pyplot as plt |