我是靠谱客的博主 傲娇手套,这篇文章主要介绍tensorflow——乘法,现在分享给大家,希望可以做个参考。

  线性代数中,乘法是很重要的运算,具体的矩阵乘法原理可以翻教材,或看一下阮大神的这篇文章:http://www.ruanyifeng.com/blog/2015/09/matrix-multiplication.html。

  在tensorflow中,经常使用以下几种乘法:

  1. 点乘  即常数与向量相乘或向量点乘
    sess = tf.Session()
    a = tf.constant([ 0.1, 0.4, 1.2], dtype=tf.float32)
    b = tf.constant([10.0, 5.0, 1.0], dtype=tf.float32)
    c = 2.0
    print(sess.run(a * b))
    print(sess.run(c * a))

     

  2. 矩阵相乘
    sess = tf.Session()
    a = np.random.random((4, 3))
    b = np.random.random((3, 5))
    print(sess.run(tf.matmul(a, b)))

     

  3. 内积
    c = np.random.random((1, 5))
    print(sess.run(tf.multiply(b, c)))

     

  

转载于:https://www.cnblogs.com/estragon/p/9916304.html

最后

以上就是傲娇手套最近收集整理的关于tensorflow——乘法的全部内容,更多相关tensorflow——乘法内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(169)

评论列表共有 0 条评论

立即
投稿
返回
顶部