Skip to content

Instantly share code, notes, and snippets.

View Smilels's full-sized avatar
🍀
I love penguins, panda, and monkey!!!

Shuang Li Smilels

🍀
I love penguins, panda, and monkey!!!
View GitHub Profile
@shangshang-wang
shangshang-wang / bottom_up.py
Created July 13, 2020 08:48
Fibonacci problem using dynamic programming, original from CS Dojo on Youtube
def fib_bottom_up(n):
if n == 1 or n == 2:
return 1
bottom_up = [None] * (n+1)
bottom_up[1] = 1
bottom_up[2] = 1
for i in range(3, n+1):
bottom_up[i] = bottom_up[i-1] + bottom_up[i-2]
return bottom_up[n]
@jeasinema
jeasinema / smooth_plot.py
Last active February 26, 2019 08:15
Plot smooth curve like other people do
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
def smooth(y, box_pts):
box_pts = max(box_pts, 1) if len(y) > box_pts else 1
box = np.ones(box_pts)/box_pts
y_smooth = np.convolve(y, box, mode='valid')
return y_smooth
@jeasinema
jeasinema / augmentations.py
Created June 4, 2018 13:27
Generic augmentation
import torch
from torchvision import transforms
import cv2
import numpy as np
import types
from numpy import random
def intersect(box_a, box_b):
max_xy = np.minimum(box_a[:, 2:], box_b[2:])
@jubjamie
jubjamie / pb_viewer.py
Created March 31, 2017 10:01
Load .pb into Tensorboard
import tensorflow as tf
from tensorflow.python.platform import gfile
with tf.Session() as sess:
model_filename ='PATH_TO_PB.pb'
with gfile.FastGFile(model_filename, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
g_in = tf.import_graph_def(graph_def)
LOGDIR='/logs/tests/1/'
train_writer = tf.summary.FileWriter(LOGDIR)