Skip to content

Instantly share code, notes, and snippets.

View tigerneil's full-sized avatar
🎯
Focusing

Xiaohu Zhu tigerneil

🎯
Focusing
View GitHub Profile
@tigerneil
tigerneil / pytorch_custom_backward.cpp
Created August 13, 2021 09:49 — forked from mikehamer/pytorch_custom_backward.cpp
An example of using the PyTorch C++ API to implement a custom forward and backward function
// An example of using the PyTorch C++ API to implement a custom forward and backward function
#include <iostream>
#include <vector>
#include <torch/torch.h>
#include <torch/csrc/autograd/variable.h>
#include <torch/csrc/autograd/function.h>
#include <torch/csrc/autograd/VariableTypeUtils.h>
#include <torch/csrc/autograd/functions/utils.h>
@tigerneil
tigerneil / mac-setup-redis.md
Created September 13, 2020 12:09 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@tigerneil
tigerneil / download.py
Created September 29, 2018 16:31 — forked from aowal/download.py
A Python script downloading all ICLR and NIPS papers from openreview.net
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import requests
import os
def download_all_papers(base_url, save_dir, driver_path):
driver = webdriver.Chrome(driver_path)
@tigerneil
tigerneil / setproxy
Created August 12, 2018 05:23 — forked from beradrian/setproxy
Set proxy for npm and git
# set a proxy
set HTTP_PROXY=
set HTTPS_PROXY=%HTTP_PROXY%
npm config set proxy %HTTP_PROXY%
npm config set https.proxy %HTTPS_PROXY%
npm config set https-proxy %HTTPS_PROXY%
git config --global http.proxy %HTTP_PROXY%
git config --global https.proxy %HTTPS_PROXY%
# unset proxy
@tigerneil
tigerneil / Welcome file.md
Created July 27, 2018 03:41
Welcome file

Welcome to StackEdit!

Hi! I'm your first Markdown file in StackEdit. If you want to learn about StackEdit, you can read me. If you want to play with Markdown, you can edit me. If you have finished with me, you can just create new files by opening the file explorer on the left corner of the navigation bar.

Files

StackEdit stores your files in your browser, which means all your files are automatically saved locally and are accessible offline!

Create files and folders

{-# LANGUAGE GADTs #-}
{-
The following code is based on experimental code by Aslan Askerov
based on Ramsey and Pfeffers "Stochastic Lambda Calculus and Monads of
Probability Distributions". Implementation of random n is from
Audebaud and Paulin-Mohring paper, so is the random walk example.
This gist is used here http://madsbuch.com/blog/the-probability-monad/
The class hierarchy is as follows:
import cv2
import os
import sys
import random
out_dir = './my_faces'
if not os.path.exists(out_dir):
os.makedirs(out_dir)
name: "iris"
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "label"
include: {
phase: TRAIN
}
hdf5_data_param {
@tigerneil
tigerneil / draw_neural_net.py
Created July 11, 2017 09:27 — forked from craffel/draw_neural_net.py
Draw a neural network diagram with matplotlib!
import matplotlib.pyplot as plt
def draw_neural_net(ax, left, right, bottom, top, layer_sizes):
'''
Draw a neural network cartoon using matplotilb.
:usage:
>>> fig = plt.figure(figsize=(12, 12))
>>> draw_neural_net(fig.gca(), .1, .9, .1, .9, [4, 7, 2])
loss=tf.reduce_mean(-elbo)
lr=tf.constant(0.001)
train_op=tf.train.AdamOptimizer(learning_rate=lr).minimize(loss,var_list=slim.get_model_variables())
init_op=tf.initialize_all_variables()
# get data
data = input_data.read_data_sets('/tmp/', one_hot=True).train
BATCH_SIZE=100
NUM_ITERS=50000
tau0=1.0 # initial temperature