Skip to content

Instantly share code, notes, and snippets.

View danqing's full-sized avatar
🐱
Cat on Keyboard

Danqing Liu danqing

🐱
Cat on Keyboard
View GitHub Profile
@danqing
danqing / update.py
Created March 17, 2016 20:27
Check updates for pip packages
#!/usr/bin/env python
import xmlrpclib
import pip
pypi = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
for dist in pip.get_installed_distributions():
available = pypi.package_releases(dist.project_name)
if not available:
# Try to capitalize pkg name
@danqing
danqing / w2v_scratch.py
Created August 2, 2016 18:46
Some scratch of w2v experiments
import numpy
from numpy.linalg import norm
from nltk.corpus import stopwords
from nltk import download
download('stopwords')
stop_words = stopwords.words('english')
sset = [
'whats the weather like',
from __future__ import print_function
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.optimizers import RMSprop
batch_size = 128
num_classes = 10
@danqing
danqing / ml.py
Last active August 23, 2017 08:08
Machine learning for humans - What is machine learning 02 - www.tinymind.ai
class FlipPredictor(object):
def __init__(self):
self.tries = 0 # Total tries so far.
self.guess = 5 # Current guess.
def predict(self, previous):
"""Predict # heads in the next 10 flips.
previous is # heads in the previous 10 flips. That's what we learn from!
@danqing
danqing / not_ml.py
Last active August 23, 2017 04:40
Machine learning for humans - What is machine learning 01 - www.tinymind.ai
from datetime import datetime
def predict_head_or_tail():
current_second = datetime.now().second
return 'head' if current_second % 2 else 'tail'
predict_head_or_tail() # 50/50 chance for head/tail
Verifying my Blockstack ID is secured with the address 16DThYAyWydSWE6D2tHYsuYYFJTxAVDK4Y https://explorer.blockstack.org/address/16DThYAyWydSWE6D2tHYsuYYFJTxAVDK4Y

Keybase proof

I hereby claim:

  • I am danqing on github.
  • I am danqing (https://keybase.io/danqing) on keybase.
  • I have a public key ASCOgKDXtW1K03A5_coDVN3qeBJSUQjriIw3hqQEWt7YxQo

To claim this, I am signing this object:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.