Skip to content

Instantly share code, notes, and snippets.

View dingran's full-sized avatar
🎮

Ran Ding dingran

🎮
View GitHub Profile
@dingran
dingran / expand_dict.py
Created October 28, 2019 02:00
Function to expand master hyperparamter to create a list of hp dicts
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},
#!/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 21:39 — forked from jychstar/miniflow.py
miniflow in Udacity nanodegree
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 January 15, 2020 06:58
Google Cloud Compute virtual machine set up with GPU

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 November 30, 2023 22:43
Python implementation of Dijkstra's algorithm, single source all desinations and single source single destination
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