This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reproducing Roblox DistilBERT Medium Post | |
# https://blog.roblox.com/2020/05/scaled-bert-serve-1-billion-daily-requests-cpus/ | |
# | |
# 1. Launch C5 12xlarge with Deep Learning AMI (Ubuntu 18.04) Version 32.0 (ami-0dc2264cd927ca9eb) | |
# 2. pip install transformers[torch] | |
# 3. python reproduce_roblox_distilbert.py | |
import timeit | |
from transformers import DistilBertTokenizerFast, \ | |
DistilBertForSequenceClassification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class foo: | |
def __eq__(self, o): | |
return False | |
t = (foo(),) | |
t2 = (t[0],) | |
t == t2 # True | |
t[0] == t2[0] # False | |
t[0] is t2[0] # True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
) | |
func main() { | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
import numpy as np | |
import numba | |
file_name = sys.argv[1] # one document per line | |
num_topics = int(sys.argv[2]) | |
num_iterations = int(sys.argv[3]) | |
alpha = float(sys.argv[4]) | |
alpha0 = float(sys.argv[5]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def sqrt(x, high, low, e): | |
mid = (high + low) / 2.0 | |
square = mid * mid | |
if (square >= x and square - x <= e) or (square < x and x - square <= e): | |
return mid | |
elif square > x: | |
return sqrt(x, high, mid, e) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import permutations | |
perms = permutations(range(6)) | |
def check(p): | |
i1 = p.index(0) < p.index(3) | |
i2 = p.index(1) < p.index(4) | |
i3 = p.index(2) < p.index(1) | |
i4 = p.index(2) < p.index(5) | |
i5 = p.index(3) < p.index(4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For each line of the input file, remove nonalphanumeric characters, | |
// lowercase all letters, remove stopwords, and write the result to the output | |
// file. I used the answer here as a template for reading/writing files: | |
// http://stackoverflow.com/questions/1821811/how-to-read-write-from-to-file/9739903#9739903 | |
package main | |
import ( | |
"bufio" | |
"fmt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sentences = [s for rev in reviews for s in rev.split(".")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print 'hello world' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import codecs | |
url = 'http://www.instapaper.com/m' | |
params = {'u': 'http://techcrunch.com/2012/04/30/bn-8-k-microsoft-paying-180m-advance-on-nook-for-windows-8-125m-for-content-tech-acquisition/'} | |
r = requests.get(url, params=params) | |
# r.text holds the response from the server. It appears to be unicode in this case. | |
f = codecs.open("foo.html", mode="w", encoding="UTF-8") | |
f.write(r.text) |
NewerOlder