Skip to content

Instantly share code, notes, and snippets.

View liaocs2008's full-sized avatar
🎯
Focusing

Leo liaocs2008

🎯
Focusing
View GitHub Profile
@liaocs2008
liaocs2008 / gist:ac4091d5f1b28bf517623edede76fba9
Last active December 19, 2016 23:00
Understanding in convolutions
import numpy as np
# http://www.songho.ca/dsp/convolution/convolution.html#separable_convolution
# https://www.mathworks.com/help/signal/ug/linear-and-circular-convolution.html
# make circular convolution equivalent to linear convolution
# M = 13
# N = 7
"""
real part
[[ 2.98023224e-08 0.00000000e+00 2.98023224e-08]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00]]
img part
[[ 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 2.98023224e-08 0.00000000e+00]]
real part
"""
newA
[[1 2 1]
[1 1 1]
[2 4 2]]
L, U = LU([(3-1,2-1,0),(3-1,2-1,3)], newA)
L= [[ 1. 0. 0.]
[-0. 1. -0.]
[ 0. 3. 1.]]
"""
First Pass:
( 5 1 4 2 8 ) –> ( 1 5 4 2 8 ), Here, algorithm compares the first two elements, and swaps since 5 > 1.
( 1 5 4 2 8 ) –> ( 1 4 5 2 8 ), Swap since 5 > 4
( 1 4 5 2 8 ) –> ( 1 4 2 5 8 ), Swap since 5 > 2
( 1 4 2 5 8 ) –> ( 1 4 2 5 8 ), Now, since these elements are already in order (8 > 5), algorithm does not swap them.
Second Pass:
( 1 4 2 5 8 ) –> ( 1 4 2 5 8 )
( 1 4 2 5 8 ) –> ( 1 2 4 5 8 ), Swap since 4 > 2
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=https://liaocs2008.github.io/">
<script type="text/javascript">
window.location.href = "https://liaocs2008.github.io/"
</script>
<title>Siyu Liao</title>
</head>
@liaocs2008
liaocs2008 / eyeriss_vgg_train_val.prototxt
Created February 12, 2020 19:10
Eyeriss-VGG-Caffemodel
# model + meanfile, https://drive.google.com/drive/folders/1GF_hyCkw46SVxQhP0NSVB4WJraYzlhUp?usp=sharing
# I0208 21:55:14.949070 18811 caffe.cpp:309] Loss: 1.65299
# I0208 21:55:14.949090 18811 caffe.cpp:321] loss3/loss3 = 1.65299 (* 1 = 1.65299 loss)
# I0208 21:55:14.949101 18811 caffe.cpp:321] loss3/top-1 = 0.607879
# I0208 21:55:14.949111 18811 caffe.cpp:321] loss3/top-5 = 0.838562
#
name: "eyeriss"
layer {
@liaocs2008
liaocs2008 / alist2np.py
Created August 11, 2020 19:29
Generate np array from alist format
## note, run with py27
import itertools
import numpy as np
from lpdec.codes import BinaryLinearBlockCode
from lpdec.codes.ldpc import ArrayLDPCCode
from lpdec.channels import *
from lpdec.decoders.iterative import IterativeDecoder
@liaocs2008
liaocs2008 / 1D_random_walk.py
Last active June 9, 2021 03:57
1D Random Walk
"""
start at x, each step either walk +1 or -1. If we arrive at 0 or n, then we stop.
question: what's the probability to stop at 0 and n with starting position x?
theoretically: P[stop at 0] = (n-x)/n, P[stop at n] = x/n
simulation results in the format "x, (P[stop at 0], P[stop at n])":
2 (0.98032, 0.01968)
@liaocs2008
liaocs2008 / coin_perspective.py
Created February 22, 2022 05:24
scrapping results from "thecoinperspective.com"
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from bs4 import BeautifulSoup
import pandas as pd
import time
options = Options()
options.add_argument('--headless')
@liaocs2008
liaocs2008 / google_photo_sort_by_name.sh
Last active October 21, 2022 03:18
sort images by names via modifying timestamp for google photos
# after running the script, use google photos their built-in timestamp based sorting function
i=0
find ./ -name "*.jpg" | sort | while read filename; do
i=$((i+1))
time=`date --date="-${i} seconds" '+%Y:%m:%d-%T'`
#echo $time
jhead -mkexif $filename