tensorflow 1.x practical tutorial (1) - simple constant calculation

Target

This article aims to introduce the introductory knowledge points and practical examples of tensorflow. I hope that newbies can be proficient in tensorflow related operations after learning.

Simple constant arithmetic code

import tensorflow as tf
v1 = tf.constant([[5,6]])
v2 = tf.constant([[2],[4]])
p1 = tf.matmul(v1, v2)
p2 = tf.matmul(v2, v1)
with tf.Session() as sess: # 因为这里没有变量,都是常量,所以直接可以进行运算,输出值
    print(sess.run(p1))
    print(sess.run(p2))
复制代码

output result

[[34]]
[[10 12]
 [20 24]]    
复制代码

Reference in this article

Reference for this article: blog.csdn.net/qq_19672707…

Guess you like

Origin juejin.im/post/7085887711529140261