Skip to content

Instantly share code, notes, and snippets.

View tegg89's full-sized avatar
🎯
Focusing

tegg89

🎯
Focusing
  • United States
View GitHub Profile
@tegg89
tegg89 / min-char-rnn.py
Created June 28, 2016 08:23 — 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)
@tegg89
tegg89 / prediction_input.py
Created April 21, 2017 07:07
video-prediction
# Copyright 2016 The TensorFlow Authors All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
import numpy as np
import tensorflow as tf
import os
from tensorflow.python.platform import app
from tensorflow.python.platform import flags
from prediction_input import build_tfrecord_input
from prediction_model import construct_model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tegg89
tegg89 / GMM.ipynb
Created September 11, 2018 04:32
GMM in PyTorch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tegg89
tegg89 / estimator.md
Created October 18, 2018 12:08
How to use tf.estimator

tf.estimator

The Estimator is a high-level API that is officially provided by TensorFlow. One of the advantages of using tf.estimator is that the code automatically builds a graph and a tensorboard itself. A user only needs to specify required arguments, such as features, optimizer, and labels, and plug into the estimator class. Just like PyTorch, the Estimator can easily switch to training, evaluation, or test modes without creating individual methods. Also, estimators are built upon the tf.keras.layers which simplifies the customization. It is preferred to know the Estimator usage because TensorFlow offers TPUEstimator which extends to the Estimator class.

The entire structure of constructing estimator model is shown below.

def model_fn(features, targets, mode, params):
@tegg89
tegg89 / mnist.py
Created October 31, 2018 05:04
MNIST data
from sklearn.datasets import fetch_mldata
import urllib
import scipy
try:
mnist = fetch_mldata('MNIST original')
except urllib.error.HTTPError as ex:
print("Could not download MNIST data from mldata.org, trying alternative...")
# Alternative method to load MNIST, if mldata.org is down
@tegg89
tegg89 / dqn_fruit.py
Created March 5, 2019 05:25 — forked from kastnerkyle/dqn_fruit.py
Implementation of DQN, Double DQN, Bootstrap DQN, and Bootstrap DQN with Randomized Prior in PyTorch on a toy environment
# extending on code from
# https://github.com/58402140/Fruit
import os
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
import copy
import time
from collections import Counter