Skip to content

Instantly share code, notes, and snippets.

Avatar
🎮

Ran Ding dingran

🎮
View GitHub Profile
@dingran
dingran / expand_dict.py
Created Oct 28, 2019
Function to expand master hyperparamter to create a list of hp dicts
View expand_dict.py
import itertools
import copy
### Example usage ###
# In [13]: import pprint
# ...: master_hp_dict = dict(anneal_KLD=Expand(True, False), bs=1024, n_epochs=Expand(2, 10, 20), mlp=[10,30])
# ...: hp_list = dict_expand(master_hp_dict)
# ...: pprint.pprint(hp_list)
# [{'anneal_KLD': True, 'bs': 1024, 'mlp': [10, 30], 'n_epochs': 2},
# {'anneal_KLD': True, 'bs': 1024, 'mlp': [10, 30], 'n_epochs': 10},
View git-bash-prompt.sh
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@dingran
dingran / miniflow.py
Created May 5, 2018 — forked from jychstar/miniflow.py
miniflow in Udacity nanodegree
View miniflow.py
import numpy as np
class Node(object):
"""
Base class for nodes in the network.
Arguments:
`inbound_nodes`: A list of nodes with edges into this node.
"""
def __init__(self, inbound_nodes=[]):
@dingran
dingran / google-cloud-gpu-instance-setup.md
Last active Jan 15, 2020
Google Cloud Compute virtual machine set up with GPU
View google-cloud-gpu-instance-setup.md

Google Cloud Compute virtual machine set up with GPU

VNC related

First, install desktop environment and vncsever

sudo apt-get install ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install vnc4server
@dingran
dingran / dijkstra.py
Last active Jun 12, 2021
Python implementation of Dijkstra's algorithm, single source all desinations and single source single destination
View dijkstra.py
from collections import defaultdict
def build_graph(edge_list):
graph = defaultdict(list)
seen_edges = defaultdict(int)
for src, dst, weight in edge_list:
seen_edges[(src, dst, weight)] += 1
if seen_edges[(src, dst, weight)] > 1: # checking for duplicated edge entries
continue