美文网首页
tensorflow实战-1.常量

tensorflow实战-1.常量

作者: 科幻不再未来 | 来源:发表于2016-10-17 20:15 被阅读0次
#coding=utf-8

#常量使用
import tensorflow as tf


# 创建两个常量,分别为1X2,2X1
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])

# product等于两个矩阵乘积
product = tf.matmul(matrix1, matrix2)

# 启动session
sess = tf.Session()

# tf需要通过sess.run才能真实运行,并得到结果
with tf.Session() as sess:
  result = sess.run([product])
  print(result)
  print(sess.run(product))

相关文章

网友评论

      本文标题:tensorflow实战-1.常量

      本文链接:https://www.haomeiwen.com/subject/fdxzyttx.html