Skip to content

Instantly share code, notes, and snippets.

View dylancashman's full-sized avatar

Dylan Cashman dylancashman

View GitHub Profile
@dylancashman
dylancashman / min-char-rnn.py
Created June 30, 2017 21:59 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@dylancashman
dylancashman / gist:6869084
Created October 7, 2013 14:38
Utf8Cleaner for encoding problems.
module Utf8Cleaner
def to_utf8(new_value)
if new_value.is_a? String
begin
# Try it as UTF-8 directly
new_value.force_encoding('UTF-8')
unless new_value.valid_encoding?
# Some of it might be old Windows code page
new_value.encode!( 'UTF-8', 'Windows-1252' )
end