Skip to content

Instantly share code, notes, and snippets.

View liuhengyue's full-sized avatar
🎯
Focusing

Hengyue (Henry) Liu liuhengyue

🎯
Focusing
View GitHub Profile
@liuhengyue
liuhengyue / pytorch_zero_weights_experiment.py
Created September 4, 2019 19:05
In Pytorch, if weights are all zero, the forward and backward speed is fast when running on GPU but not on CPU.
from collections import OrderedDict
import timeit
import torch
import torch.nn as nn
# a simple network
modules = OrderedDict()
n_conv = 10
n_linear = 2
@liuhengyue
liuhengyue / plot_confusion_matrix.png
Created December 5, 2018 09:29 — forked from hitvoice/plot_confusion_matrix.png
Generate matrix plot for confusion matrix with pretty annotations.
plot_confusion_matrix.png
@liuhengyue
liuhengyue / useful_tools
Created September 20, 2018 18:17
useful_tools
nbdime - diff/merge jupyter notebook
@liuhengyue
liuhengyue / comparision_tf_and_np_where.py
Created September 6, 2018 20:20
Comparision of tf.where and np.where
"""
Comparision of tf.where and np.where
"""
import tensorflow as tf
import numpy as np
X_batch = np.eye(5, dtype='bool')
X_batch[1,1] =False
@liuhengyue
liuhengyue / useful_linux_commands
Last active February 25, 2019 21:56
useful linux commands
nvtop - gpu top
ncdu - check disk usage
systemctl restart NetworkManager.service - restart network
### merge several pdfs
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=finished.pdf
Soln06018.pdf Soln06046.pdf Soln06054.pdf Soln06060.pdf
@liuhengyue
liuhengyue / set_cuda_device.py
Last active August 23, 2018 21:08
Select GPU
import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = ""
@liuhengyue
liuhengyue / disp_multiple_images.py
Created June 14, 2018 20:44 — forked from soply/disp_multiple_images.py
Plot multiple images with matplotlib in a single figure. Titles can be given optionally as second argument.
import matplotlib.pyplot as plt
import numpy as np
def show_images(images, cols = 1, titles = None):
"""Display a list of images in a single figure with matplotlib.
Parameters
---------
images: List of np.arrays compatible with plt.imshow.
@liuhengyue
liuhengyue / CUBLAS_STATUS_NOT_INITIALIZED
Created June 13, 2018 22:40
CUBLAS_STATUS_NOT_INITIALIZED issue solver
sudo rm -rf ~/.nv/
https://devtalk.nvidia.com/default/topic/1007071/cuda-setup-and-installation/cuda-error-when-running-matrixmulcublas-sample-ubuntu-16-04/post/5169223/