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
#include "FastLED.h" | |
#include <Adafruit_NeoPixel.h> | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, 8, NEO_BRG + NEO_KHZ800); | |
void setup() { | |
strip.begin(); | |
strip.show(); // Initialize all pixels to 'off' | |
} | |
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
extern const TProgmemRGBPalette16 autumnleaves FL_PROGMEM = { | |
0Xb70c0c, 0Xc71221, 0Xdc0606, 0Xfa250c, | |
0Xfc9105, 0Xfcb108, 0X318d03, 0X9dd523, | |
0Xfc9105, 0Xfcb108, 0X318d03, 0X9dd523, | |
0Xb70c0c, 0Xc71221, 0Xdc0606, 0Xfa250c | |
}; | |
extern const TProgmemRGBPalette16 desert FL_PROGMEM = { | |
0X000000, 0Xeb6810, 0Xeb8d10, 0Xd35d0e, | |
0X8b3d09, 0XFFC233, 0X000000, 0Xeb6810, |
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
''' | |
GRU layer implementation orignally taken from https://github.com/ottokart/punctuator2 | |
''' | |
class GRULayer(object): | |
def __init__(self, rng, n_in, n_out, minibatch_size): | |
super(GRULayer, self).__init__() | |
# Notation from: An Empirical Exploration of Recurrent Network Architectures | |
self.n_in = n_in |
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
from tf.contrib.rnn import GRUCell | |
cell = GruCell() | |
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
import tensorflow as tf | |
lstm = tf.contrib.rnn.BasicLSTMCell(lstm_size) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
''' | |
Tools to take a directory of txt files and convert them to TF records | |
''' | |
from collections import defaultdict, Counter | |
import numpy as np | |
import tensorflow as tf | |
PAD = "<PAD>" | |
EOS = "<EOS>" | |
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
class BibPreppy(Preppy): | |
''' | |
We'll slightly extend to way we right tfrecords to store the id of the book it came from | |
''' | |
def __init__(self,tokenizer_fn): | |
super(BibPreppy,self).__init__(tokenizer_fn) | |
self.book_map ={} | |
def sequence_to_tf_example(self, sequence, book_id): | |
id_list = self.sentance_to_id_list(sequence) |
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
if __name__=="__main__": | |
#make the iterators and next element op | |
next_element, training_init_op, validation_init_op = prepare_dataset_iterators(batch_size=32) | |
... | |
for epoch in range(1000): | |
#Initialize the iterator to consume training data | |
sess.run(training_init_op) | |
while True: | |
#As long as the iterator is not empty |
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
import tensorflow as tf | |
from preppy import BibPreppy | |
def expand(x): | |
''' | |
Hack. Because padded_batch doesn't play nice with scalres, so we expand the scalar to a vector of length 1 | |
:param x: | |
:return: |
OlderNewer