Python data_utils.rev_vocab() Examples
The following are 10
code examples of data_utils.rev_vocab().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
data_utils
, or try the search function
.
Example #1
Source File: neural_gpu_trainer.py From DOTA_models with Apache License 2.0 | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")
Example #2
Source File: neural_gpu_trainer.py From yolo_v2 with Apache License 2.0 | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")
Example #3
Source File: neural_gpu_trainer.py From Gun-Detector with Apache License 2.0 | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")
Example #4
Source File: neural_gpu_trainer.py From hands-detection with MIT License | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")
Example #5
Source File: neural_gpu_trainer.py From object_detection_kitti with Apache License 2.0 | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")
Example #6
Source File: neural_gpu_trainer.py From object_detection_with_tensorflow with MIT License | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")
Example #7
Source File: neural_gpu_trainer.py From HumanRecognition with MIT License | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")
Example #8
Source File: neural_gpu_trainer.py From g-tensorflow-models with Apache License 2.0 | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")
Example #9
Source File: neural_gpu_trainer.py From models with Apache License 2.0 | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")
Example #10
Source File: neural_gpu_trainer.py From multilabel-image-classification-tensorflow with MIT License | 6 votes |
def print_vectors(embedding_key, vocab_path, word_vector_file): """Print vectors from the given variable.""" _, rev_vocab = wmt.initialize_vocabulary(vocab_path) vectors_variable = [v for v in tf.trainable_variables() if embedding_key == v.name] if len(vectors_variable) != 1: data.print_out("Word vector variable not found or too many.") sys.exit(1) vectors_variable = vectors_variable[0] vectors = vectors_variable.eval() l, s = vectors.shape[0], vectors.shape[1] data.print_out("Printing %d word vectors from %s to %s." % (l, embedding_key, word_vector_file)) with tf.gfile.GFile(word_vector_file, mode="w") as f: # Lines have format: dog 0.045123 -0.61323 0.413667 ... for i in xrange(l): f.write(rev_vocab[i]) for j in xrange(s): f.write(" %.8f" % vectors[i][j]) f.write("\n")