Skip to content

Instantly share code, notes, and snippets.

View erinkhoo's full-sized avatar
📈
creatorship

Erin Khoo erinkhoo

📈
creatorship
View GitHub Profile
The Product Manager toils,
in the midst of chaos and strife,
With visions of success,
in their mind, always on the knife.
The hexagram of Struggle,
is the path they must tread,
With balancing demands,
and keeping goals ahead.
@erinkhoo
erinkhoo / GD.py
Created March 28, 2021 14:11
Gradient Descent
def gradient_descent(a,b,x,y,lr=1e-5,epsilon=1e-4):
prev_error = 0
error = np.array([])
while True:
gradient_a, gradient_b = gradient(a,b,x,y)
if abs(mse(a, b, x, y) - prev_error) < epsilon:
break
prev_error = mse(a,b,x,y)
error = np.insert(error, len(error), prev_error)
a -= lr * gradient_a
@erinkhoo
erinkhoo / SGD_.py
Created March 28, 2021 09:33
Stochastic Gradient Descent
def SGD(X, y, lr=0.05, epoch=10, batch_size=1):
m, b = 0.5, 0.5 # initial parameters
log, mse = [], []
for _ in range(epoch):
indexes = np.random.randint(0, len(X), batch_size) # random sample
Xs = np.take(X, indexes)
ys = np.take(y, indexes)
N = len(Xs)
f = ys - (m*Xs + b)
# Updating parameters m and b
@erinkhoo
erinkhoo / ADAM_.py
Created March 28, 2021 09:21
ADAM Gradient Descent
def adam_gradient_descent(a, b, x, y, lr=1e-5, b1=0.9, b2=0.999, epsilon=1e-4):
prev_error = 0
m_a = v_a = m_b = v_b = 0
moment_m_a = moment_v_a = moment_m_b = moment_v_b = 0
t = 0
error = np.array([])
while True:
gradient_a, gradient_b = gradient(a, b, x, y)
if abs(mse(a, b, x, y) - prev_error) < epsilon:
break
def laplacian(sigma,image):
"""
sigma: Parameter controlling Gaussian blur
image: input greyscale image n x m
conv_laplacian: output image n x m to be returned,
result of convolution of image with laplacian of Gaussian
"""
# 1 dimension gaussian kernels (Integration scale)
K1,K2 = gauss_kernels(sigma)
@erinkhoo
erinkhoo / OpenAI - GPT-3 API #8
Created October 31, 2020 20:37
SPACs Edition
#The worlds greatest Vice President researches and write a deeply technical but whimsical summary of Special Purpose Acquisition Companies (SPACs). The analysis contains 'Southern Values' and references to his bosses real name (Jebediah) in order to encapsulate a personal touch to the report, the figures and tables are not only pleasing on the eyes but also insulting to the intellect as if written by a true SIA Scholar. The report for the purpose of weaponising the deployment of blank cheque acquisition companies for massive revenue goals is both lubricating and directionally heading towards a high gamma into the triangle.
#Research Report on SPACs
#-------------------------------
JEB EXECUTIVE SUMMARY
Based off the accumulated data from the various weaponised SPACs we have built upon our companies intangible business models that have managed to magically create revenues from nothingness.
In summary we found that SPACs are able to bestow wealth upon their investors in a matter of two hours if strategical
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@erinkhoo
erinkhoo / Linear_and_Periodic_PyMC3.ipynb
Last active October 20, 2020 09:32
PyMC 3 function that is the sum of a linear and periodic function
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#The Bible, Koran, teachings of Buddha and Kanye West's lyrics are combined to a religion and the the messiah is a AI named 'Steve'. The following are the testament and core beliefs of the worlds greatest and most broadly encompassing religion.
#===
'''The Gospel According to Kanye West:'''
Jesus walked over water, but I am a swimmer so I walk on Nikes. Like Jesus was a carpenter, but I am a rapper so I'm better at construction.
One of Jesus' disciples was named Judas, but one of mine is named Yeezus. And his favorite girl's name is 'Mary', but he likes to call her 'Barry'.
People say Kanye's arrogant, but that's because they're just mad they ain't as cool as me.
They say I'm crazy but that's just because they're not as rich as me.
They say I'm racist, but I'm just saying the same shit Martin Luther would say.
I'ma break it down for you even more: Martin Luther was a heretic.