Skip to content

Instantly share code, notes, and snippets.

View ccj5351's full-sized avatar
🎯
Focusing

Changjiang Cai ccj5351

🎯
Focusing
View GitHub Profile
@ccj5351
ccj5351 / build-a-heap-with-O(n)-time-complexity.md
Last active September 29, 2024 00:24
build-a-heap-O(n)-time

How can building a heap be O(n) time complexity?

Several highly voted answers have given excellent explanations. I will show several figures to show the proof clearly and hope it is easy to understand.

Height of a Heap

The height of heap h = O(log(N)), where N is the number of (internal) nodes.

Note: ◯ for internal nodes, and □ for external nodes or leaf nodes; values are only saved at internal nodes.
Solutions of Leet Code questions.
@ccj5351
ccj5351 / extract_ILSVRC.sh
Created September 2, 2020 03:33 — forked from BIGBALLON/extract_ILSVRC.sh
script for ImageNet data extract.
#!/bin/bash
#
# script to extract ImageNet dataset
# ILSVRC2012_img_train.tar (about 138 GB)
# ILSVRC2012_img_val.tar (about 6.3 GB)
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory
#
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md
#
# train/
@ccj5351
ccj5351 / docker-cleanup-resources.md
Created June 15, 2020 19:07 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ccj5351
ccj5351 / itera_dataloader_example.py
Created February 19, 2020 03:06
Modified code with the article "How to Build a Streaming DataLoader with PyTorch" at https://medium.com/speechmatics/how-to-build-a-streaming-dataloader-with-pytorch-a66dd891d9dd.
import random
from itertools import chain, cycle, islice
import torch.utils.data as data
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
import time
import torch
import numpy as np
@ccj5351
ccj5351 / BOOSTwithPython3
Created February 10, 2020 08:57 — forked from melvincabatuan/BOOSTwithPython3
Compile BOOST with Python3 support
1. Check Python3 root
>>> import sys
>>> import os
>>> sys.executable
'/usr/local/bin/python3'
OR
$ which python3
/usr/local/bin/python3
@ccj5351
ccj5351 / install_docker_ubuntu_16.04.sh
Created September 3, 2019 23:14 — forked from gauravkaila/install_docker_ubuntu_16.04.sh
Install Docker and nvidia-docker on Ubuntu-16.04
#!/bin/bash
# add the GPG key for the official Docker repository to the system
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# add the Docker repository to APT sources
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# update the package database with the Docker packages from the newly added repo
sudo apt-get update
@ccj5351
ccj5351 / tensorflow_rename_variables.py
Created June 19, 2019 18:37 — forked from batzner/tensorflow_rename_variables.py
Small python script to rename variables in a TensorFlow checkpoint
import sys, getopt
import tensorflow as tf
usage_str = 'python tensorflow_rename_variables.py --checkpoint_dir=path/to/dir/ ' \
'--replace_from=substr --replace_to=substr --add_prefix=abc --dry_run'
def rename(checkpoint_dir, replace_from, replace_to, add_prefix, dry_run):
checkpoint = tf.train.get_checkpoint_state(checkpoint_dir)
@ccj5351
ccj5351 / Test-your-tensorflow-installation-2019-03-20 21-22-53.png
Last active March 21, 2019 01:28 — forked from Brainiarc7/build-tensorflow-from-source.md
Build Tensorflow from source, for better performance on Ubuntu.
Test-your-tensorflow-installation-2019-03-20 21-22-53.png
@ccj5351
ccj5351 / VOClabelcolormap.m
Last active June 11, 2021 13:06 — forked from wllhf/VOClabelcolormap.py
Python implementation of the color map function for the PASCAL VOC data set.
%Official Matlab version can be found in the PASCAL VOC devkit
%http://host.robots.ox.ac.uk/pascal/VOC/voc2012/index.html#devkit
% VOCLABELCOLORMAP Creates a label color map such that adjacent indices have different
% colors. Useful for reading and writing index images which contain large indices,
% by encoding them as RGB images.
%
% CMAP = VOCLABELCOLORMAP(N) creates a label color map with N entries.
function cmap = labelcolormap(N)