Skip to content

Commit

Permalink
third-tensorflow: matmul comment
Browse files Browse the repository at this point in the history
fourth-tensorflow: added + python native types
  • Loading branch information
Thanirin committed Feb 10, 2019
1 parent cb9c6aa commit e89f71a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions fourth-tensorflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import tensorflow as tf

# Python native types

t_0 = 19
t_1 = [b"apple", b"peach", b"grape"]

t_2 = [[True, False, False],
[False, False, False],
[False, True, False]]

with tf.Session() as session:
print(session.run(tf.zeros_like(t_0)))
print(session.run(tf.ones_like(t_0)))

print(session.run(tf.zeros_like(t_1)))
# print(session.run(tf.ones_like(t_1))) # expect string, got 1 (int) instead

print(session.run(tf.zeros_like(t_2)))
print(session.run(tf.ones_like(t_2)))
2 changes: 1 addition & 1 deletion third-tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
print(session.run(tf.add_n([a, b, a])))
print(session.run(tf.multiply(a, b)))
# print(session.run(tf.matmul(a, b)))
print(session.run(tf.matmul(tf.reshape(a, shape=[1, 2]), tf.reshape(b, shape=[2, 1]))))
print(session.run(tf.matmul(tf.reshape(a, shape=[1, 2]), tf.reshape(b, shape=[2, 1])))) # matrix multiplication
print(session.run(tf.div(a, b)))
print(session.run(tf.mod(a, b)))

Expand Down

0 comments on commit e89f71a

Please sign in to comment.