class LossHistory(Callback):
def __init__(self, X_train, y_train, layer_index):
super(Callback, self).__init__()
self.layer_index = layer_index
if X_train.shape[0] >= 1000:
mask = np.random.choice(X_train.shape[0], 1000)
self.X_train_subset = X_train[mask]
self.y_train_subset = y_train[mask]
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
# Incomplete row major matrix implementation. | |
type RowMajorMatrix{T} <: AbstractMatrix{T} | |
col_major::Matrix{T} | |
end | |
row_major{T}(c::Matrix{T}) = RowMajorMatrix{T}(c) | |
Base.size{T}(m::RowMajorMatrix{T}, n::Int) = if n == 1 size(m.col_major, 2) elseif n == 2 size(m.col_major, 1) else size(m.col_major, n) end | |
Base.getindex{T}(m::RowMajorMatrix{T}, i, j) = m.col_major[j, i] | |
function setindex!{T}(m::RowMajorMatrix{T}, value, i, j) |
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
require 'oauth' | |
require 'launchy' | |
require 'nokogiri' | |
class User | |
def authenticate(consumer_key, consumer_secret, site) | |
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, site) | |
request_token = consumer.get_request_token | |
puts "Authorize Follower and then paste in the PIN:" |
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
echo "-----> Installing via pip, but setting environment vars first." | |
export BLAS=$(pwd)/vendor/lib/atlas-base/atlas/libblas.a | |
export LAPACK=$(pwd)/vendor/lib/atlas-base/atlas/liblapack.a | |
export ATLAS=$(pwd)/vendor/lib/atlas-base/libatlas.a | |
export LIBRARY_PATH=$(pwd)/vendor/lib:$(pwd)/lib/atlas-base:$(pwd)/lib/atlas-base/atlas | |
export LD_LIBRARY_PATH=$(pwd)/vendor/lib:$(pwd)/vendor/lib/atlas-base:$(pwd)/vendor/lib/atlas-base/atlas | |
pip install --use-mirrors scikit-learn |
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
heroku config:add BUILDPACK_URL=https://github.com/ToonTimbermont/heroku-buildpack-python |
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
def get_H_n(X): | |
return X[:, -1, :] # get last element from time dim | |
def get_Y(X): | |
return X[:, :110, :] # get first xmaxlen elem from time dim | |
def get_R(X): | |
Y, alpha = X.values() # Y should be (L,k) and alpha should be (L,) and ans should be (k,) |
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
module HMM | |
using Distributions | |
import Distributions.rand | |
import Distributions.fit | |
immutable HiddenMarkovModel{TP, K} | |
theta::Vector{TP} | |
A::Matrix{Float64} |
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
# Based on the example from the TensorFlow repository: https://github.com/tensorflow/tensorflow/ | |
# https://github.com/tensorflow/tensorflow/blob/671baf080238025da9698ea980cd9504005f727c/tensorflow/examples/learn/text_classification_character_rnn.py | |
from __future__ import absolute_import | |
from __future__ import division | |
from __future__ import print_function | |
import argparse | |
import sys |
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
describe("getTweets - Server", function () { | |
var server, fakeData = [ /* ... */ ]; | |
before(function () { | |
// Doesn’t work :( It’s JSONP! | |
server = sinon.fakeServer.create(); | |
server.respondWith( | |
"GET", | |
"https://api.twitter.com/.../elijahmanor.json?count=5", | |
[200, { "Content-Type": "application/json" }, JSON.stringify(fakeData)] |
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
#!/usr/bin/env python | |
# coding: utf-8 | |
"""Sampling Sequence Data from model""" | |
import numpy as np | |
import tensorflow as tf | |
import json | |
import cPickle as pickle | |
import itertools as it | |
from rnnlib import PTBModel |
OlderNewer