Skip to content

Instantly share code, notes, and snippets.

View jjone36's full-sized avatar
💭
I may be slow to respond.

Jiwon jjone36

💭
I may be slow to respond.
View GitHub Profile
import numpy as np
# input data
input_layer = np.array([[5], [2]])
input_layer.shape
# initialize wegihts & bias
weights_1 = np.array([[2, -2], [3, 1]])
weights_1.shape
# define activation function
def relu(x):
return np.where(x <= 0, 0, x)
# input data
input_layer = np.array([[5], [2]])
weights_1 = np.array([[2, -2], [3, 1]])
weights_2 = np.array([[1], [2]])
# computation of first hidden layer
import numpy as np
# what is convolution? How to capture the edge by padding?
array = np.array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
kernel = np.array([-1, 1])
conv = np.array([0, 0, 0, 0, 0, 0, 0, 0])
# convolution
conv[1] = (kernel * array[0:2]).sum()
import numpy as np
# one-hot-encoding
categories = np.array(['shirt', 'dress', 'shoe'])
labels = ['shoe', 'shirt', 'shoe', 'shirt', 'dress', 'dress', 'dress']
ohe_labels = np.zeros([len(labels), len(categories)])
for m in range(len(labels)):
# find the location of the label
# Create a function to vetorize all the ingredients and get t-SNE at once
def cosmetic_map(option_1, option_2):
''' Define a function creating a dataframe for each option '''
df = cosm[cosm['Label'] == option_1][cosm[option_2] == 1]
df = df.reset_index()
# embedding each ingredients
word_index_map = {}
index_word_map = []
current_index = 0
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import plotly.graph_objs as go
# Step 1. Launch the application
app = dash.Dash()
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import plotly.graph_objs as go
# Step 1. Launch the application
app = dash.Dash()
import cv2
import numpy as np
# Step 1. Define callback function
drawing = False
ix = -1
iy = -1
def draw_rectangle(event, x, y, flags, params):
import cv2
import numpy as np
# Step 1. Define detect function
face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_default.xml')
def detect_face(img):
img_copy = img.copy()
face_rects = face_cascade.detectMultiScale(img_copy)
# 1. Create variables as a tensor
a = tf.constant(2, tf.int32)
b = tf.Variable(10, tf.float32)
# 2. Write opertaions between them
c = tf.multiply(a, b)
# 3. Initialize variables
init = tf.global_variables_initializer()