官术网_书友最值得收藏!

Matrix multiplication

Matrix multiplication of matrices A and B is a third matrix, C:

C = AB

The element-wise product of matrices is called a Hadamard product and is denoted as A.B.

The dot product of two vectors x and y of the same dimensionality is the matrix product x transposing y. Matrix product C = AB is like computing Ci,j as the dot product between row i of matrix A and column j of matrix B:

The following example shows the Hadamard product and dot product using tensor objects:

import tensorflow as tf

mat1 = tf.constant([[4, 5, 6],[3,2,1]])
mat2 = tf.constant([[7, 8, 9],[10, 11, 12]])

# hadamard product (element wise)
mult = tf.multiply(mat1, mat2)

# dot product (no. of rows = no. of columns)
dotprod = tf.matmul(mat1, tf.transpose(mat2))

with tf.Session() as sess:
print(sess.run(mult))
print(sess.run(dotprod))

The output of the listing is shown as follows:

[[28 40 54][30 22 12]]
[[122 167][ 46 64]]
主站蜘蛛池模板: 万源市| 靖州| 棋牌| 阜宁县| 全南县| 光泽县| 奉新县| 花莲县| 香港 | 吉安县| 蓬安县| 南澳县| 南京市| 福海县| 咸宁市| 出国| 紫金县| 视频| 蒲城县| 泰顺县| 兴仁县| 海淀区| 樟树市| 沁阳市| 宁河县| 香河县| 清水河县| 乡城县| 车致| 肥乡县| 前郭尔| 秦安县| 铜川市| 来安县| 永德县| 霍城县| 周至县| 禹州市| 岳西县| 昔阳县| 迭部县|