Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View danijar's full-sized avatar

Danijar Hafner danijar

View GitHub Profile
@danijar
danijar / edit_dirs
Last active April 29, 2018 12:50
Text based tool move and delete directories
#!/usr/bin/python3
"""Move or delete directories via your text editor.
Installation:
- Install sh.py via `pip3 install sh`.
- Save this file into a directory in your $PATH, for example `~/bin`.
"""
import argparse
import tempfile
@danijar
danijar / tf_char_rnn.py
Last active March 21, 2024 16:55
Simple character-level recurrent language model implemented in TensorFlow.
"""Character based language modeling with multi-layer GRUs.
To train the model:
python3 tf_char_rnn.py --mode training \
--logdir path/to/logdir --corpus path/to/corpus.txt
To generate text from seed words:
python3 tf_char_rnn.py --mode sampling \
import numpy as np
class Network:
def __init__(self, num_inputs, num_hidden, num_output,
init_weight_scale=0.5):
self.w1 = np.random.normal(
0, init_weight_scale, (num_inputs + 1, num_hidden))
self.w2 = np.random.normal(
algorithms:
- config:
| frame_skip: 6
| history: 6
| replay_capacity: 5e4
name: DQN
train_steps: 200000
type: DQN
envs:
- SimpleGather-v0

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
@danijar
danijar / relations_semeval_glove_not_found.txt
Created May 22, 2016 13:20
Words from the Semeval 2010 dataset not found in Glove
keygen
uprises
non-infected
counter-weight
pipetted
quispel
rooster-whistles
moisturisers
enfeoffing
pre-adolescents
@danijar
danijar / blog_tensorflow_variable_sequence_labelling.py
Last active May 15, 2022 14:28
TensorFlow Variable-Length Sequence Labelling
# 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_classification.py
Last active December 31, 2021 10:04
TensorFlow Variable-Length Sequence Classification
# 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):
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_sequence_labelling.py
Last active January 12, 2024 15:18
TensorFlow Sequence Labelling
# 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__