This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |