Skip to content

Instantly share code, notes, and snippets.

View spitis's full-sized avatar

spitis

View GitHub Profile
@spitis
spitis / JSProblems.md
Created December 24, 2014 03:08
JS Problem Samples

##Problem Samples

####Logging hello world How would you output the string "Hello world!" to the javascript console.

Answer:

console.log("Hello World!");

@spitis
spitis / gist:47a243774808a9c124f9
Last active October 18, 2015 23:16
Simple node tictactoe
var assert = require('assert');
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function game() {
var board = [
#!/usr/bin/perl
# Program to filter Wikipedia XML dumps to "clean" text consisting only of lowercase
# letters (a-z, converted from A-Z), and spaces (never consecutive).
# All other characters are converted to spaces. Only text which normally appears
# in the web browser is displayed. Tables are removed. Image captions are
# preserved. Links are converted to normal text. Digits are spelled out.
# Written by Matt Mahoney, June 10, 2006. This program is released to the public domain.
This file has been truncated, but you can view the full file.
Star Wars: Episode 1:The Phantom Menace
TITLE CARD : A long time ago in a galaxy far, far away....
A vast sea of stars serves as the backdrop for the main title, followed by
a roll up, which crawls up into infinity.
EPISODE 1 THE PHANTOM MENACE
Turmoil has engulfed the Galactic Republic. The taxation of trade routes to
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@spitis
spitis / bnlstm.py
Created February 2, 2017 03:05
Batch normalized LSTM Cell for Tensorflow
"""adapted from https://github.com/OlavHN/bnlstm to store separate population statistics per state"""
import tensorflow as tf, numpy as np
RNNCell = tf.nn.rnn_cell.RNNCell
class BNLSTMCell(RNNCell):
'''Batch normalized LSTM as described in arxiv.org/abs/1603.09025'''
def __init__(self, num_units, is_training_tensor, max_bn_steps, initial_scale=0.1, activation=tf.tanh, decay=0.95):
"""
* max bn steps is the maximum number of steps for which to store separate population stats
"""
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
def ptb_iterator(raw_data, batch_size, num_steps, steps_ahead=1):
"""Iterate on the raw PTB data.
This generates batch_size pointers into the raw PTB data, and allows
minibatch iteration along these pointers.
Args:
raw_data: one of the raw data outputs from ptb_raw_data.
batch_size: int, the batch size.
num_steps: int, the number of unrolls.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.