tf.matmul(a,b...)
Multiplies matrix a
by matrix b
, producing a
* b
.
tf.multiply(x, y, name=None)
Returns x * y element-wise.
import numpy as np
import tensorflow as tf
A = np.array([[1,2,3],[4,5,6]],np.float32)
b = np.array([1,2,3],np.float32)
# tf.matmul和np.matmul功能一样
np.matmul(A,b)
array([ 14., 32.], dtype=float32)
# tf.multiply和np.multiply功能一样
C = np.multiply(A,b)
C
array([[ 1., 4., 9.],
[ 4., 10., 18.]], dtype=float32)
C_sigmoid = tf.sigmoid(C)
with tf.Session() as sess:
print(sess.run(C_sigmoid))
[[ 0.7310586 0.98201376 0.99987662]
[ 0.98201376 0.99995458 1. ]]
1 / (1 + np.exp(-18))
0.9999999847700205