Skip to content

Instantly share code, notes, and snippets.

@trungquy
trungquy / blaze_face_detect.py
Created January 13, 2020 23:56 — forked from ogl4jo3/blaze_face_detect.py
Demo BlazeFace model.
import cv2
import time
import math
import numpy as np
import tensorflow as tf
class SsdAnchorsCalculatorOptions:
def __init__(self, input_size_width, input_size_height, min_scale, max_scale
, num_layers, feature_map_width, feature_map_height
, strides, aspect_ratios, anchor_offset_x=0.5, anchor_offset_y=0.5
@trungquy
trungquy / Feature Value Types.md
Last active March 5, 2019 02:08
Categorical Encoding
  • Categoical data - a fixed list of values, eg: gender, country/market/language, age group
  • Ordinal data - order is important. Exmaple: ranking, datetime
  • Numeric data
@trungquy
trungquy / flatten_schema.py
Created December 21, 2018 03:08
Pyspark - Utilities
# source: https://stackoverflow.com/questions/37471346/automatically-and-elegantly-flatten-dataframe-in-spark-sql
from pyspark.sql.types import StructType, ArrayType
def flatten(schema, prefix=None):
fields = []
for field in schema.fields:
name = prefix + '.' + field.name if prefix else field.name
dtype = field.dataType
if isinstance(dtype, ArrayType):
dtype = dtype.elementType
@trungquy
trungquy / ml_learning_notes.txt
Created September 5, 2018 00:32
Machine Learning Notes
But here some highlights that might be of interest:
- discussion of approximation error, estimation error, and optimization error, rather than the more vague “bias / variance” trade off;
- full treatment of gradient boosting, one of the most successful ML algorithms in use today (along with neural network models);
- more emphasis on conditional probability modeling than is typical (you give me an input, I give you a probability distribution over outcomes — useful for anomaly detection and prediction intervals, among other things),
- geometric explanation for what happens with ridge, lasso, and elastic net in the [very common in practice] case of correlated features;
- guided derivation of when the penalty forms and constraint forms of regularization are equivalent, using Lagrangian duality (in homework), proof of the representer theorem with simple linear algebra,
- independent of kernels, but then applied to kernelize linear methods;
- a general treatment of backpropagation
@trungquy
trungquy / VSCode Settings
Created July 29, 2018 23:51
settings.json
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/*.pyc": true
},
"telemetry.enableTelemetry": false,
@trungquy
trungquy / rsync_parallel.sh
Created July 8, 2016 04:20 — forked from rcoup/rsync_parallel.sh
Parallel-ise an rsync transfer when you want multiple concurrent transfers happening,
#!/bin/bash
set -e
# Usage:
# rsync_parallel.sh [--parallel=N] [rsync args...]
#
# Options:
# --parallel=N Use N parallel processes for transfer. Defaults to 10.
#
# Notes:
@trungquy
trungquy / pg-pong.py
Created June 2, 2016 23:29 — forked from karpathy/pg-pong.py
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@trungquy
trungquy / Assign fixed IP for docker container.txt
Created May 24, 2016 23:41
Assign fixed IP for docker container
# create a new bridge network with your subnet and gateway for your ip block
$ docker network create --subnet 203.0.113.0/24 --gateway 203.0.113.254 iptastic
# run a nginx container with a specific ip in that block
$ docker run --rm -it --net iptastic --ip 203.0.113.2 nginx
# curl the ip from any other place (assuming this is a public ip block duh)
$ curl 203.0.113.2
# BOOM golden
@trungquy
trungquy / io_color.py
Created April 20, 2016 04:00
[Python] Color Printing Utility
class color(object):
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'