Skip to content

Instantly share code, notes, and snippets.

View chris-chris's full-sized avatar
🎯
Focusing

Chris Hoyean Song chris-chris

🎯
Focusing
View GitHub Profile
@chris-chris
chris-chris / lstm.py
Last active August 27, 2018 02:59 — forked from karpathy/gist:587454dc0146a6ae21fc
An efficient, batched LSTM.
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@chris-chris
chris-chris / min-char-rnn.py
Last active August 30, 2018 09:59 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
Korean translation
최소 버전의 단어 레벨 바닐라 RNN 모델. Andrej Karpathy (@karpathy) 작성
- Korean comments
- Python3 compatibility update
"""
@chris-chris
chris-chris / cnn-in-numpy.py
Last active June 24, 2018 16:35
Convolution in numpy
import numpy as np
import tensorflow as tf
from tensorflow.python.framework import dtypes
# 1. Setting up initial values
x = np.zeros((7, 7, 3))
x[:, :, 0] = np.mat(
"0 0 0 0 0 0 0;0 0 1 0 1 0 0;0 2 1 0 1 2 0;0 0 2 0 0 1 0;0 2 0 1 0 0 0;0 0 0 1 2 2 0;0 0 0 0 0 0 0"
).A
import tensorflow as tf
import numpy as np
from tensorflow.python.ops import variable_scope
from tensorflow.python.ops import init_ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import variables
from tensorflow.contrib.rnn.python.ops import rnn_cell
res = []
@chris-chris
chris-chris / simple_gradient_descent.py
Last active November 14, 2021 04:25
simple 1-step gradient descent
# From udacity Machine Learning Nanodegree course
import numpy as np
# Define sigmoid function
def sigmoid(x):
return 1/(1+np.exp(-x))
# Derivative of the sigmoid function
def sigmoid_derivative(x):