Skip to content

Instantly share code, notes, and snippets.

View mlzxy's full-sized avatar

Xinyu Zhang mlzxy

  • Rutgers University
  • New Brunswick, NJ
View GitHub Profile
@mlzxy
mlzxy / gist:64ef62b4c54b7ea9478b21e95c5db153
Created March 26, 2019 10:23 — forked from fdob/gist:5983637
in-diff: Use inotify to capture changes to a file, and output diffs to STDOUT. Needs inotify-tools.
#!/bin/bash
# hook into inotify to watch a file, and generate
# diffs for changes in real-time
#
# requires inotify-tools (apt-get install inotify-tools)
#
# @author Filipe Dobreira <filipe.dobreira@ez.no>
usage() {
echo "Usage:"
echo " in-diff <file>|help"
@mlzxy
mlzxy / tune_cifar.py
Created April 28, 2018 04:20 — forked from zhreshold/tune_cifar.py
Cifar10 with gluon model
import argparse
import logging
import random
import time
import mxnet as mx
from mxnet import nd
from mxnet import image
from mxnet import gluon
from mxnet import autograd
import numpy as np
@mlzxy
mlzxy / train_imagenet.py
Created April 28, 2018 04:19 — forked from zhreshold/train_imagenet.py
Train imagenet using gluon
import argparse, time
import logging
logging.basicConfig(level=logging.INFO)
fh = logging.FileHandler('training.log')
logger = logging.getLogger()
logger.addHandler(fh)
import mxnet as mx
from mxnet import gluon
from mxnet.gluon import nn
@mlzxy
mlzxy / gru.py
Created November 15, 2017 02:39 — forked from danijar/gru.py
Gated Recurrent Unit with Layer norm and Xavier initializer
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
class GRU(tf.contrib.rnn.RNNCell):
def __init__(
@mlzxy
mlzxy / inception_resnet_v2_train_val_2ndtry.txt
Created July 29, 2017 13:00 — forked from revilokeb/inception_resnet_v2_train_val_2ndtry.txt
Caffe train_val for learning inception-resnet-v2 - 2ndtry
name: "Inception_Resnet2_Imagenet"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
I use the first
—– BEGIN LICENSE —–
Michael Barnes
Single User License
EA7E-821385
8A353C41 872A0D5C DF9B2950 AFF6F667
C458EA6D 8EA3C286 98D1D650 131A97AB
AA919AEC EF20E143 B361B1E7 4C8B7F04
@mlzxy
mlzxy / what-forces-layout.md
Created January 9, 2017 01:57 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
import tensorflow as tf
from tensorflow.python.framework import ops
import numpy as np
# Define custom py_func which takes also a grad op as argument:
def py_func(func, inp, Tout, stateful=True, name=None, grad=None):
# Need to generate a unique name to avoid duplicates:
rnd_name = 'PyFuncGrad' + str(np.random.randint(0, 1E+8))
import tensorflow as tf
import numpy as np
if __name__ == '__main__':
np.random.seed(1)
# the size of the hidden state for the lstm (notice the lstm uses 2x of this amount so actually lstm will have state of size 2)
size = 1
# 2 different sequences total
batch_size= 2
# the maximum steps for both sequences is 10
@mlzxy
mlzxy / install_opencv2.4.9.sh
Last active September 29, 2016 22:15 — forked from HuangFJ/install_opencv2.4.9.sh
centos 6.5 + opencv 2.4.9 + ffmpeg 0.10.11 + python 2.7.7 自动安装脚本
#! /bin/bash
sudo yum install -y gcc g++ gtk+-devel libjpeg-devel libtiff-devel jasper-devel libpng-devel zlib-devel cmake unzip sqlite-devel readline-devel bzip2-devel openssl-devel ncurses-devel
sudo yum install -y yum-priorities
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum install -y eigen3-devel --enablerepo=epel
su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm'
sudo yum install -y ffmpeg-devel
export PYTHON_PREFIX=/usr/local/python-2.7.7