Skip to content

Instantly share code, notes, and snippets.

@rouseguy
rouseguy / seq2seq_keras.py
Created July 19, 2016 09:17
Sequence to Sequence - Keras
%%time
# -*- coding: utf-8 -*-
'''An implementation of sequence to sequence learning for performing addition
Input: "535+61"
Output: "596"
Padding is handled by using a repeated sentinel character (space)
Input may optionally be inverted, shown to increase performance in many tasks in:
"Learning to Execute"
http://arxiv.org/abs/1410.4615
@rouseguy
rouseguy / config.toml
Created July 16, 2017 08:23
sample hugo blog config.toml
baseurl = "the github.io link"
title = "title of the blog"
theme = "hugo-theme-nix"
languageCode = "en-us"
#disqusShortname = "your_disqus_shortname"
[menu]
[[menu.header]]
name = "blog"
weight = 0
@rouseguy
rouseguy / vimrc
Created August 9, 2017 18:53
vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
syntax enable
set background=light
let g:solarized_contrast="high"
colorscheme solarized
set guifont=Hack:h20
set showmatch
@rouseguy
rouseguy / zshrc
Created August 9, 2017 18:56
zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/bsubrama/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
import numpy as np
def fizzbuzz(number):
if number % 15 == 0:
return np.array(["fizzbuzz"], dtype="object")
elif number % 5 == 0:
return np.array(["buzz"], dtype="object")
elif number % 3 == 0:
return np.array(["fizz"], dtype="object")
else:
@rouseguy
rouseguy / helpers.py
Last active March 10, 2018 05:12
helper functions for the deep learning workshop
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import keras
from tensorflow.examples.tutorials.mnist import input_data
import os
# Helper to get the labels for each class of Fashion Mnist
def fashion_mnist_label():
labels = {
import numpy as np
def input_generate_data(data, SEQ_LENGTH=SEQ_LENGTH, VOCAB_SIZE=VOCAB_SIZE, char_to_ix = char_to_ix):
X = np.zeros((int(len(data)/SEQ_LENGTH), SEQ_LENGTH, VOCAB_SIZE))
y = np.zeros((int(len(data)/SEQ_LENGTH), SEQ_LENGTH, VOCAB_SIZE))
for i in range(0, int(len(data)/SEQ_LENGTH)):
X_sequence = data[i*SEQ_LENGTH:(i+1)*SEQ_LENGTH]
X_sequence_ix = [char_to_ix[value] for value in X_sequence]
import numpy as np
def input_generate_data(data, SEQ_LENGTH=20, VOCAB_SIZE=30, char_to_ix = {}):
X = np.zeros((int(len(data)/SEQ_LENGTH), SEQ_LENGTH, VOCAB_SIZE))
y = np.zeros((int(len(data)/SEQ_LENGTH), SEQ_LENGTH, VOCAB_SIZE))
for i in range(0, int(len(data)/SEQ_LENGTH)):
X_sequence = data[i*SEQ_LENGTH:(i+1)*SEQ_LENGTH]
X_sequence_ix = [char_to_ix[value] for value in X_sequence]
X = np.zeros((int(len(data)/SEQ_LENGTH), SEQ_LENGTH, VOCAB_SIZE))
y = np.zeros((int(len(data)/SEQ_LENGTH), SEQ_LENGTH, VOCAB_SIZE))
for i in range(0, int(len(data)/SEQ_LENGTH)):
X_sequence = data[i*SEQ_LENGTH:(i+1)*SEQ_LENGTH]
X_sequence_ix = [char_to_ix[value] for value in X_sequence]
input_sequence = np.zeros((SEQ_LENGTH, VOCAB_SIZE))
for j in range(SEQ_LENGTH):
input_sequence[j][X_sequence_ix[j]] = 1.
X[i] = input_sequence
import numpy as np
import pandas as pd
import altair as alt
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Helper to get the labels for each class of Fashion Mnist
def fashion_mnist_label():
labels = {