Skip to content

Instantly share code, notes, and snippets.

View eecrazy's full-sized avatar

Zhongyang Li eecrazy

View GitHub Profile
def unit_normalize(a):
x1,_=tf.meshgrid(tf.reduce_min(a,1),tf.ones(a.get_shape()[1]),indexing='ij')
x2,_=tf.meshgrid(tf.sub(tf.reduce_max(a,1),tf.reduce_min(a,1)),tf.ones(a.get_shape()[1]),indexing='ij')
return tf.div(tf.sub(a,x1),x2)
global_step = tf.Variable(0, trainable=False)
starter_learning_rate = 0.1
learning_rate = tf.train.exponential_decay(starter_learning_rate, global_step,
100000, 0.96, staircase=True)
# Passing global_step to minimize() will increment it at each step.
learning_step = (
tf.train.GradientDescentOptimizer(learning_rate)
.minimize(...my loss..., global_step=global_step)
)
import tensorflow as tf
sess = tf.InteractiveSession()
x = tf.Variable([1.0, 2.0])
a = tf.constant([3.0, 3.0])
tf.mul(a,a).eval()
//a and b are input matrixs
//we can first enlarge a and b by some degree
a=tf.mul(10000*tf.ones(a.get_shape()),a).eval()
b=tf.mul(10000*tf.ones(b.get_shape()),b).eval()
c=tf.sqrt(tf.reduce_sum(tf.mul(a,a),axis=1)) d=tf.sqrt(tf.reduce_sum(tf.mul(b,b),axis=1))
e=tf.reduce_sum(tf.mul(a,b),axis=1)
f=tf.mul(c,d)
r=tf.div(e,f)
rr=tf.sub(tf.ones(r.get_shape()),r)
@eecrazy
eecrazy / NLTK English text preprocessing
Last active April 28, 2018 17:45
NLTK English text preprocessing
import nltk
text="Dan's parents were overweight.,Dan was overweight as well.,The doctors told his parents it was unhealthy.,His parents understood and decided to make a change.,They got themselves and Dan on a diet.".split(',')
print [sen.lower() for sen in text]
print [nltk.word_tokenize(sen) for sen in text]
wnl=nltk.WordNetLemmatizer()

NLTK API to Stanford NLP Tools compiled on 2015-12-09

Stanford NER

With NLTK version 3.1 and Stanford NER tool 2015-12-09, it is possible to hack the StanfordNERTagger._stanford_jar to include other .jar files that are necessary for the new tagger.

First set up the environment variables as per instructed at https://github.com/nltk/nltk/wiki/Installing-Third-Party-Software

(This is the text of the keynote I gave at Startup Riot 2009. Will update when video becomes available.)

Hi everyone, I’m Chris Wanstrath, and I’m one of the co-founders of GitHub.

GitHub, if you haven’t heard of it, has been described as “Facebook for developers.” Which is great when talking about GitHub as a website, but not so great when describing GitHub as a business. In fact, I think we’re the polar opposite of Facebook as a business: we’re small, never took investment, and actually make money. Some have even called us successful.

Which I’ve always wondered about. Success is very vague, right? Probably even relative. How do you define it?

After thinking for a while I came up with two criteria. The first is profitability. We employ four people full time, one person part time, have thousands of paying customers, and are still growing. In fact, our rate of growth is increasing – which means January was our best month so far, and February is looking pretty damn good.