Skip to content

Instantly share code, notes, and snippets.

Danijar Hafner danijar

View GitHub Profile
View bug_matplotlib_threading.py
import random
import time
import threading
import matplotlib.pyplot as plt
class Plot:
def __init__(self):
plt.ion()
View flask_restful_custom_error_handlers.py
import flask_restful
class Api(flask_restful.Api):
"""
Patch Flask-style custom error handling into the Flask-RESTful api class.
"""
def __init__(self, *args, **kwargs):
super(Api, self).__init__(*args, **kwargs)
View blog_tensorflow_scope_decorator.py
# Working example for my blog post at:
# https://danijar.github.io/structuring-your-tensorflow-models
import functools
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
def doublewrap(function):
"""
A decorator decorator, allowing to use the decorator to be used without
@danijar
danijar / blog_tensorflow_sequence_classification.py
Last active Apr 29, 2019
TensorFlow Sequence Classification
View blog_tensorflow_sequence_classification.py
# Example for my blog post at:
# https://danijar.com/introduction-to-recurrent-networks-in-tensorflow/
import functools
import sets
import tensorflow as tf
def lazy_property(function):
attribute = '_' + function.__name__
View blog_tensorflow_sequence_labelling.py
# Example for my blog post at:
# http://danijar.com/introduction-to-recurrent-networks-in-tensorflow/
import functools
import sets
import tensorflow as tf
def lazy_property(function):
attribute = '_' + function.__name__
View script_tfidf.py
import argparse
import collections
import re
TOKEN_REGEX = re.compile(r'[A-Za-z]+')
BLACKLIST = set([
'pdf', 'and', 'the', 'proceedings', 'conference', 'ieee', 'for',
'about', 'details', 'data', 'with', 'arxiv', 'preprint', 'advances'])
def tokenize(line):
@danijar
danijar / blog_tensorflow_variable_sequence_classification.py
Last active Mar 21, 2019
TensorFlow Variable-Length Sequence Classification
View blog_tensorflow_variable_sequence_classification.py
# Working example for my blog post at:
# http://danijar.com/variable-sequence-lengths-in-tensorflow/
import functools
import sets
import tensorflow as tf
from tensorflow.models.rnn import rnn_cell
from tensorflow.models.rnn import rnn
def lazy_property(function):
@danijar
danijar / blog_tensorflow_variable_sequence_labelling.py
Last active Oct 31, 2019
TensorFlow Variable-Length Sequence Labelling
View blog_tensorflow_variable_sequence_labelling.py
# Working example for my blog post at:
# http://danijar.com/variable-sequence-lengths-in-tensorflow/
import functools
import sets
import tensorflow as tf
from tensorflow.models.rnn import rnn_cell
from tensorflow.models.rnn import rnn
def lazy_property(function):
@danijar
danijar / relations_semeval_glove_not_found.txt
Created May 22, 2016
Words from the Semeval 2010 dataset not found in Glove
View relations_semeval_glove_not_found.txt
keygen
uprises
non-infected
counter-weight
pipetted
quispel
rooster-whistles
moisturisers
enfeoffing
pre-adolescents
View 2016-06-10-char-rnn-sample.md

Char-RNN Sample

Parameters

dataset = ArxivAbstracts(
    categories='stat.ML cs.NE cs.LG math.OC',
    keywords='neural network deep')
max_length = 50
sampling_temperature = 0.5
You can’t perform that action at this time.