Skip to content

Instantly share code, notes, and snippets.

View cjsutton77's full-sized avatar
🏠
Working from home

Christian Sutton cjsutton77

🏠
Working from home
  • Houston TX
View GitHub Profile
@cjsutton77
cjsutton77 / goldenratio.ipynb
Created March 22, 2026 01:27
GoldenRatio.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include <stdio.h>
#include <stdlib.h>
typedef struct vector {
int xhat;
int yhat;
int zhat;
} vector;
vector* scalar(int s, vector* S);
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}%')
@cjsutton77
cjsutton77 / ffbp.py
Created May 13, 2020 02:00
feedforward backprop
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)
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))
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))
@cjsutton77
cjsutton77 / import.py
Created May 13, 2020 00:43
Import needed libraries
import numpy as np
from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt