"awq/git@developer.sourcefind.cn:OpenDAS/autoawq.git" did not exist on "d7badefcd533f54cccf7be66e876457bef142bb7"
Commit dfedef45 authored by Neal Wu's avatar Neal Wu Committed by GitHub
Browse files

Merge pull request #1471 from tensorflow/import-xrange-directly

Import xrange directly from six.moves for lm_1b
parents 1cd1f9d4 c5326615
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
""" """
import os import os
import sys import sys
import six
import numpy as np import numpy as np
from six.moves import xrange
import tensorflow as tf import tensorflow as tf
from google.protobuf import text_format from google.protobuf import text_format
...@@ -178,7 +178,7 @@ def _SampleModel(prefix_words, vocab): ...@@ -178,7 +178,7 @@ def _SampleModel(prefix_words, vocab):
prefix = [vocab.word_to_id(w) for w in prefix_words.split()] 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()] prefix_char_ids = [vocab.word_to_char_ids(w) for w in prefix_words.split()]
for _ in six.moves.range(FLAGS.num_samples): for _ in xrange(FLAGS.num_samples):
inputs = np.zeros([BATCH_SIZE, NUM_TIMESTEPS], np.int32) inputs = np.zeros([BATCH_SIZE, NUM_TIMESTEPS], np.int32)
char_ids_inputs = np.zeros( char_ids_inputs = np.zeros(
[BATCH_SIZE, NUM_TIMESTEPS, vocab.max_word_length], np.int32) [BATCH_SIZE, NUM_TIMESTEPS, vocab.max_word_length], np.int32)
...@@ -231,7 +231,7 @@ def _DumpEmb(vocab): ...@@ -231,7 +231,7 @@ def _DumpEmb(vocab):
sys.stderr.write('Finished softmax weights\n') sys.stderr.write('Finished softmax weights\n')
all_embs = np.zeros([vocab.size, 1024]) all_embs = np.zeros([vocab.size, 1024])
for i in six.moves.range(vocab.size): for i in xrange(vocab.size):
input_dict = {t['inputs_in']: inputs, input_dict = {t['inputs_in']: inputs,
t['targets_in']: targets, t['targets_in']: targets,
t['target_weights_in']: weights} t['target_weights_in']: weights}
...@@ -270,7 +270,7 @@ def _DumpSentenceEmbedding(sentence, vocab): ...@@ -270,7 +270,7 @@ def _DumpSentenceEmbedding(sentence, vocab):
inputs = np.zeros([BATCH_SIZE, NUM_TIMESTEPS], np.int32) inputs = np.zeros([BATCH_SIZE, NUM_TIMESTEPS], np.int32)
char_ids_inputs = np.zeros( char_ids_inputs = np.zeros(
[BATCH_SIZE, NUM_TIMESTEPS, vocab.max_word_length], np.int32) [BATCH_SIZE, NUM_TIMESTEPS, vocab.max_word_length], np.int32)
for i in six.moves.range(len(word_ids)): for i in xrange(len(word_ids)):
inputs[0, 0] = word_ids[i] inputs[0, 0] = word_ids[i]
char_ids_inputs[0, 0, :] = char_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