tensorflow的tf.matmul()用法详解
matmul的用法是2个矩阵相乘, 将前面矩阵的每一行分别与后面矩阵的列相乘,作为结果矩阵的行列


import tensorflow as tf
import math
import matplotlib.pyplot as plt
A = [[1,2,3],[0,1,1],[2,0,0]]
B = [[0,1,2,0],[4,3,0,0],[0,1,0,0]]
tf.compat.v1.disable_eager_execution()
sess = tf.compat.v1.InteractiveSession()
print(sess.run(tf.matmul(A,B)))
运行结果:
[[ 8 10 2 0]
[ 4 4 0 0]
[ 0 2 4 0]]