Skip to content

Instantly share code, notes, and snippets.

import time
from numpy import *
def dottest(type, dim):
t = time.time()
a = random.random((dim, dim)).astype(type)
b = random.random((dim, dim)).astype(type)
c = dot(a, b)
ct = time.time() - t
print "++++++++++++++++++++++++"
@entron
entron / understand_dnn_conv.ipynb
Created September 18, 2015 09:47
Show different convolution results between numpy and theano
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@entron
entron / nltk-intro.py
Created January 14, 2016 14:12 — forked from alexbowe/nltk-intro.py
Demonstration of extracting key phrases with NLTK in Python
import nltk
text = """The Buddha, the Godhead, resides quite as comfortably in the circuits of a digital
computer or the gears of a cycle transmission as he does at the top of a mountain
or in the petals of a flower. To think otherwise is to demean the Buddha...which is
to demean oneself."""
# Used when tokenizing words
sentence_re = r'''(?x) # set flag to allow verbose regexps
([A-Z])(\.[A-Z])+\.? # abbreviations, e.g. U.S.A.
@entron
entron / imdb_cnn_kim_small_embedding.py
Last active September 16, 2023 16:23
Keras implementation of Kim's paper "Convolutional Neural Networks for Sentence Classification" with a very small embedding size. The test accuracy is 0.853.
'''This scripts implements Kim's paper "Convolutional Neural Networks for Sentence Classification"
with a very small embedding size (20) than the commonly used values (100 - 300) as it gives better
result with much less parameters.
Run on GPU: THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python imdb_cnn.py
Get to 0.853 test accuracy after 5 epochs. 13s/epoch on Nvidia GTX980 GPU.
'''
from __future__ import print_function
@entron
entron / gist:cfb5a560f1372acb8bf7
Created February 15, 2016 14:44 — forked from wacko/gist:5577187
SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

@entron
entron / sqlite_online_backup.py
Created August 13, 2016 09:13
Online backup sqlite db with python
# Online backup a sqlite3 DB.
# python3 sqlite_online_backup.py db_to_backup.sqlite backup_db.sqlite
import sqlite3
import sqlitebck
import sys
fname_to_backup = sys.argv[1]
fname_backup = sys.argv[2]
@entron
entron / test_numpy.py
Last active June 7, 2020 10:12
Test numpy installation.
import numpy as np
import numpy.random as npr
import time
# --- Test 1
N = 100
n = 2000
A = npr.randn(n, n)
B = npr.randn(n, n)
@entron
entron / test_pytorch.py
Created August 14, 2017 18:44
Test pytorch linear algebra speed
import torch
import time
# --- Test 1
N = 10
n = 1000
A = torch.randn(n, n)
B = torch.randn(n, n)
@entron
entron / plot_dingxiang_data.ipynb
Last active February 11, 2020 15:08
Plotting data of 2019-nCoV outbreak. Data source: https://github.com/BlankerL/DXY-2019-nCoV-Data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@entron
entron / cifar10_bench.ipynb
Last active June 13, 2020 16:42
simple gpu benchmark with pytorch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.