Skip to content

Instantly share code, notes, and snippets.

View gwding's full-sized avatar

Gavin Weiguang Ding gwding

View GitHub Profile
@gwding
gwding / show_gym.py
Created June 5, 2017 19:01
quickly show how an openai gym game looks like
import sys
import gym
env = gym.make(sys.argv[1])
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample()) # take a random action
@gwding
gwding / test_pytorch_mem.py
Created May 8, 2017 00:08
test pytorch memory usage
import sys
import torch
import torch.utils
import torch.nn as nn
from torch.autograd import Variable
from torchvision import models
try:
import gpustat
except ImportError:
@gwding
gwding / test_logging.py
Created May 8, 2017 00:07
quick example of how to let logging output to a file and stdout
"""Logging to file and stdout at the same time"""
import logging
import sys
def config_logging(filename='example.log', format="%(message)s"):
logging.basicConfig(
filename=filename,
format=format,
@gwding
gwding / theano_binary_search.py
Created December 15, 2016 02:22
Use theano to do binary search over continuous monotonic increasing function
# Use theano to do binary search over continuous monotonic increasing function
import theano
import theano.tensor as T
import numpy as np
def func(x):
return T.exp(x)
@gwding
gwding / speed_test.py
Last active December 14, 2016 16:23
test interenet speed every hour
# for testing interenet speed every hour
import time
from speedtest_cli import speedtest
data_list = []
while True:
dlspeed, ulspeed = speedtest()
data_list.append((dlspeed, ulspeed, time.strftime("%H:%M:%S")))