Skip to content

Instantly share code, notes, and snippets.

View cemoody's full-sized avatar
👋

Christopher Erick Moody cemoody

👋
View GitHub Profile
@cemoody
cemoody / Barnes-Hut t-SNE Demo.ipynb
Last active October 16, 2016 06:31
Barnes-Hut t-SNE Demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cemoody
cemoody / demo_bhtsne.py
Created December 29, 2014 05:34
BH t-SNE Demo
# coding: utf-8
### Summary
# This notebook presents the Barnes-Hut implementation of t-SNE. t-SNE is used to visualize high-dimensional data in a low dimensional space that attempts preserve the pairwise high-dimensional similarities in a low-dimensional embedding. The Barnes-Hut algorithm, which is used by astrophysicists to perform N-body simulations, allows the calculation of the t-SNE embedding in $O(N log N)$ time instead of $O(N^{2})$. This effectively allows us to learn embeddings of data sets with millions of elements instead of tens of thousands.
### Install
# To try out out the BH version of t-SNE, do the following:
@cemoody
cemoody / server.py
Last active June 29, 2023 18:19
Simple SQLDict-backed Key Value Store
from flask import Flask
from flask_restful import reqparse, abort, Api, Resource
from sqlitedict import SqliteDict
from flask import jsonify, request
import json
data = SqliteDict('./data.sqlite', autocommit=True)
app = Flask(__name__)
api = Api(app)
@cemoody
cemoody / lstm2style_id.py
Last active October 30, 2016 21:21
lstm2style_id
from aa import config
import pandas as pd
import numpy as np
import os.path
import pickle
import chainer
import chainer.links as L
import chainer.functions as F
'housing social issues, affordability, rent',
'computer hardware and monitors',
'math, language, meditation and education',
'cars and entertainment',
'bing, google, facebook, search engines',
'transportation and military',
'technology in the media and society',
'finance and bitcoin',
'higher education, business and grad schools',
'sleep, stimulants, and excercise',
@cemoody
cemoody / model_wrapper.py
Created January 11, 2017 21:09
Chainer Model Wrapper
import chainer
from chainer import cuda
from chainer import training
from chainer.training import extensions
from chainer.datasets import TupleDataset
from chainer.iterators import SerialIterator
class Wrapper(object):
def __init__(self, model, batchsize=512, n_epochs=100, device=None,
embeddings_mu = nn.Embedding(n_words, n_dim)
embeddings_lv = nn.Embedding(n_words, n_dim)
...
vector_mu = embeddings_mu(c_index)
vector_lv = embeddings_lv(c_index)
def normal(mu, lv):
random = torch.FloatTensor(std.size()).normal_()
return mu + random * torch.exp(0.5 * lv)
@cemoody
cemoody / init.vim
Last active March 17, 2017 15:34
Neovim personal profile
"dein Scripts-----------------------------
if &compatible
set nocompatible " Be iMproved
endif
" Required:
set runtimepath+=/Users/moody/.vim/bundles/repos/github.com/Shougo/dein.vim
" Required:
if dein#load_state('/Users/moody/.vim/bundles')
<!DOCTYPE html>
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
</head>
<body>
<script>
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
<!DOCTYPE html>
<html>
<head>
<title> Login to See Leaderboard </title>
</head>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({