Commit b2fc63b3 authored by Edouard Fouché's avatar Edouard Fouché Committed by GitHub
Browse files

use six.moves.range instead of range

parent 0d5f3137
......@@ -17,6 +17,7 @@
"""
import os
import sys
import six
import numpy as np
import tensorflow as tf
......@@ -177,7 +178,7 @@ def _SampleModel(prefix_words, vocab):
prefix = [vocab.word_to_id(w) for w in prefix_words.split()]
prefix_char_ids = [vocab.word_to_char_ids(w) for w in prefix_words.split()]
for _ in range(FLAGS.num_samples):
for _ in six.moves.range(FLAGS.num_samples):
inputs = np.zeros([BATCH_SIZE, NUM_TIMESTEPS], np.int32)
char_ids_inputs = np.zeros(
[BATCH_SIZE, NUM_TIMESTEPS, vocab.max_word_length], np.int32)
......@@ -230,7 +231,7 @@ def _DumpEmb(vocab):
sys.stderr.write('Finished softmax weights\n')
all_embs = np.zeros([vocab.size, 1024])
for i in range(vocab.size):
for i in six.moves.range(vocab.size):
input_dict = {t['inputs_in']: inputs,
t['targets_in']: targets,
t['target_weights_in']: weights}
......@@ -269,7 +270,7 @@ def _DumpSentenceEmbedding(sentence, vocab):
inputs = np.zeros([BATCH_SIZE, NUM_TIMESTEPS], np.int32)
char_ids_inputs = np.zeros(
[BATCH_SIZE, NUM_TIMESTEPS, vocab.max_word_length], np.int32)
for i in range(len(word_ids)):
for i in six.moves.range(len(word_ids)):
inputs[0, 0] = word_ids[i]
char_ids_inputs[0, 0, :] = char_ids[i]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment