Skip to content

Commit

Permalink
Merge pull request tensorflow#11346 from taehoonlee/improve_examples
Browse files Browse the repository at this point in the history
Improve examples for Python 3 compatibility
  • Loading branch information
caisq authored Jul 8, 2017
2 parents 75f56f0 + 5f81e2b commit 4ea0457
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions tensorflow/contrib/learn/python/learn/utils/gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ def parser(path):
path_list = gc.get_paths("/tmp", parser) # contains all ten Paths
every_fifth = gc.mod_export_version(5)
print every_fifth(path_list) # shows ["/tmp/0", "/tmp/5"]
print(every_fifth(path_list)) # shows ["/tmp/0", "/tmp/5"]
largest_three = gc.largest_export_versions(3)
print largest_three(all_paths) # shows ["/tmp/7", "/tmp/8", "/tmp/9"]
print(largest_three(all_paths)) # shows ["/tmp/7", "/tmp/8", "/tmp/9"]
both = gc.union(every_fifth, largest_three)
print both(all_paths) # shows ["/tmp/0", "/tmp/5",
# "/tmp/7", "/tmp/8", "/tmp/9"]
print(both(all_paths)) # shows ["/tmp/0", "/tmp/5",
# "/tmp/7", "/tmp/8", "/tmp/9"]
# delete everything not in 'both'
to_delete = gc.negation(both)
for p in to_delete(all_paths):
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/contrib/lookup/lookup_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class MutableHashTable(LookupInterface):
default_value=-1)
table.insert(keys, values)
out = table.lookup(query_keys)
print out.eval()
print(out.eval())
```
"""

Expand Down Expand Up @@ -502,7 +502,7 @@ class MutableDenseHashTable(LookupInterface):
empty_key=0)
table.insert(keys, values)
out = table.lookup(query_keys)
print out.eval()
print(out.eval())
```
"""

Expand Down
8 changes: 4 additions & 4 deletions tensorflow/contrib/session_bundle/gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ def parser(path):
path_list = gc.get_paths("/tmp", parser) # contains all ten Paths
every_fifth = gc.mod_export_version(5)
print every_fifth(path_list) # shows ["/tmp/0", "/tmp/5"]
print(every_fifth(path_list)) # shows ["/tmp/0", "/tmp/5"]
largest_three = gc.largest_export_versions(3)
print largest_three(all_paths) # shows ["/tmp/7", "/tmp/8", "/tmp/9"]
print(largest_three(all_paths)) # shows ["/tmp/7", "/tmp/8", "/tmp/9"]
both = gc.union(every_fifth, largest_three)
print both(all_paths) # shows ["/tmp/0", "/tmp/5",
# "/tmp/7", "/tmp/8", "/tmp/9"]
print(both(all_paths)) # shows ["/tmp/0", "/tmp/5",
# "/tmp/7", "/tmp/8", "/tmp/9"]
# delete everything not in 'both'
to_delete = gc.negation(both)
for p in to_delete(all_paths):
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/python/ops/array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,10 @@ def _SliceHelperVar(var, slice_spec):
A = tf.Variable([[1,2,3], [4,5,6], [7,8,9]], dtype=tf.float32)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print sess.run(A[:2, :2]) # => [[1,2], [4,5]]
print(sess.run(A[:2, :2])) # => [[1,2], [4,5]]
op = A[:2,:2].assign(22. * tf.ones((2, 2)))
print sess.run(op) # => [[22, 22, 3], [22, 22, 6], [7,8,9]]
print(sess.run(op)) # => [[22, 22, 3], [22, 22, 6], [7,8,9]]
```
Note that assignments currently do not support NumPy broadcasting
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/python/ops/lookup_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class HashTable(InitializableLookupTableBase):
tf.contrib.lookup.KeyValueTensorInitializer(keys, values), -1)
out = table.lookup(input_tensor).
table.init.run()
print out.eval()
print(out.eval())
```
"""

Expand Down Expand Up @@ -709,7 +709,7 @@ class IdTableWithHashBuckets(LookupInterface):
num_oov_buckets)
out = table.lookup(input_tensor).
table.init.run()
print out.eval()
print(out.eval())
```
The hash function used for generating out-of-vocabulary buckets ID is handled
Expand Down

0 comments on commit 4ea0457

Please sign in to comment.