Skip to content

Instantly share code, notes, and snippets.

View michaelklachko's full-sized avatar

Michael Klachko michaelklachko

  • Mythic AI
  • Santa Barbara, CA
View GitHub Profile
@michaelklachko
michaelklachko / custom_op.py
Last active February 12, 2018 01:08
combination of tensorflow ops to transform a tensor
import numpy as np
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
def build_mask(fs, dim, debug=False):
mask = np.zeros((fs*fs, dim, dim)) #this mask will be applied to each group in conv_out
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 11 15:22:27 2017
@author: Modification of https://github.com/spro/practical-pytorch/blob/master/char-rnn-generation/char-rnn-generation.ipynb by Michael Klachko
Changes:
- added batch support
- added multi-GPU support
- minor changes to train code
"""
Created on Sun Jun 11 15:22:27 2017
@author: Modification of https://github.com/spro/practical-pytorch/blob/master/char-rnn-generation/char-rnn-generation.ipynb by Michael Klachko
Changes:
- added batch support
- added multi-GPU support
- minor changes to train code
- removed Unicode support (assume input.txt is ASCII)
@michaelklachko
michaelklachko / char-rnn_MultiGPU.py
Created June 13, 2017 20:43
char-rnn in PyTorch with DataParallel
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 11 15:22:27 2017
@author: Modification of https://github.com/spro/practical-pytorch/blob/master/char-rnn-generation/char-rnn-generation.ipynb by Michael Klachko
Changes:
- added batch support
- added multi-GPU support
- minor changes to train code
@michaelklachko
michaelklachko / gist:4e51df535f0b28bd570cef4ed240a2f0
Created June 13, 2017 19:05
char-rnn model in PyTorch for multiple GPUs
"""
Created on Sun Jun 11 15:22:27 2017
@author: Modification of https://github.com/spro/practical-pytorch/blob/master/char-rnn-generation/char-rnn-generation.ipynb by Michael Klachko
Changes:
- added batch support
- added multi-GPU support
- minor changes to train code
- removed Unicode support (assume input.txt is ASCII)
import random
import torch
import torch.nn as nn
from torch.autograd import Variable
text = open('input.txt', 'r').read()
file_len = len(text)
all_chars = ''.join(set(text))
n_chars = len(all_chars)