This file contains 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
# 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() |
This file contains 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 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) |
This file contains 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 cv2 | |
import numpy as np | |
# Step 1. Define callback function | |
drawing = False | |
ix = -1 | |
iy = -1 | |
def draw_rectangle(event, x, y, flags, params): |
This file contains 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 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() |
This file contains 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 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() |
This file contains 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
# 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 |
This file contains 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 | |
# 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 |
This file contains 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 | |
# 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() |
This file contains 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
# 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 |
This file contains 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 | |
# 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 |