Skip to content

Instantly share code, notes, and snippets.


Shuchen Du shuuchen

Block or report user

Report or block shuuchen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
from collections import defaultdict
from heapq import *
def dijkstra(edges, f, t):
g = defaultdict(list)
for l, r, c in edges:
g[l].append((c, r))
q, seen, mins = [(0, f, ())], set(), {f: 0}
shuuchen /
Last active Jun 20, 2019
An implementation of union find tree
class UT:
def __init__(self, n): = list(range(n)) = [0] * n
def find(self, x):
if[x] != x:[x] = self.find([x])
shuuchen / install_nvidia_driver.txt
Last active Jun 10, 2019
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
View install_nvidia_driver.txt
This post shows how to deal with the following error:
(base) [dushu@ip-172-20-149-210 ~]$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver.
Make sure that the latest NVIDIA driver is installed and running.
Just install the latest nvidia driver.
shuuchen /
Created May 27, 2019
Implementation of trie
from collections import defaultdict
class TrieNode:
def __init__(self):
self.isWord = False
self.children = defaultdict(TrieNode)
class Trie:
def __init__(self):
shuuchen /
Last active May 24, 2019
Using PyTorch functional APIs for image data augmentation
import torchvision.transforms.functional as F
import numpy as np
from PIL import Image
import os
from matplotlib import pyplot as plt
# input images
d = '../data/homes/test_input/'
img0 =, '352.jpg'))
img1 =, '95.jpg'))
shuuchen / file0.txt
Last active Sep 10, 2018
Pytorch でシーケンスデータを順番で読込 ref:
View file0.txt
class ImageFolderWithPaths(datasets.ImageFolder):
"""Custom dataset that includes image file paths. Extends
# override the __getitem__ method. this is the method dataloader calls
def __getitem__(self, index):
# this is what ImageFolder normally returns
original_tuple = super(ImageFolderWithPaths, self).__getitem__(index)
# the image file path
shuuchen / file0.txt
Created Aug 14, 2018
pycharm で conda 環境を構築 (windows 版) ref:
View file0.txt
Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> sys.executable
import pickle
import numpy as np
import pdb
img_width, img_height = 300, 300
box_configs = [
{'layer_width': 38, 'layer_height': 38, 'num_prior': 3, 'min_size': 30.0,
'max_size': None, 'aspect_ratios': [1.0, 2.0, 1/2.0]},
{'layer_width': 19, 'layer_height': 19, 'num_prior': 6, 'min_size': 60.0,
'max_size': 114.0, 'aspect_ratios': [1.0, 1.0, 2.0, 1/2.0, 3.0, 1/3.0]},
shuuchen / imagenet1000_clsid_to_human.txt
Created Jul 18, 2017 — forked from yrevar/imagenet1000_clsidx_to_labels.txt
text: imagenet 1000 class id to human readable labels
View imagenet1000_clsid_to_human.txt
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
You can’t perform that action at this time.