Matrix Operations
一 Code example
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
import numpy as np
A = tf.constant([[1,2,3],[4,5,6]])
B = tf.fill([3,4],3)
C = tf.constant([[1,2,3,4],[11,22,33,44]])
with tf.Session() as sess:
A_value = sess.run(A)
B_value = sess.run(B)
print('A_value\n',A_value)
print('B_value\n',B_value)
print('C_value\n',sess.run(C))
print('Matrix multiplication')
matmal = tf.matmul(A,B)
print(matmal)
print('matmal_value\n',sess.run(matmal))
print('Matrix addition')
add = tf.add(matmal,C)
print(add)
print('add_value\n',sess.run(add))
二 Operation result
正是江南好风景