tensorflow-1day入门

张量表示数据,计算图描述神经网络的计算过程(不进行计算,只是描述过程),然后会话执行计算图,

张量(tensor) 就是多维数组        阶:就是张量的维度

 

数据类型有float32和int32类型

 1 import tensorflow
 2 #定义两个常量a与b
 3 a=tensorflow.constant([[1.0,2.0]]) #一行两列张量
 4 b=tensorflow.constant([[3.0],[4.0]])#两行一列张量
 5 #搭建计算图
 6 result=tensorflow.matmul(a,b)# 矩阵乘法
 7 #打印计算图
 8 print(result)
 9 #会话计算结果
10 with tensorflow.Session() as sess:
11     print(sess.run(result))

 

  运行结果:

Tensor("MatMul:0", shape=(1, 1), dtype=float32)
2018-10-31 13:48:12.165633: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2018-10-31 13:48:12.194026: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 6. Tune using inter_op_parallelism_threads for best performance.
[[11.]]

  其中红色部分的警告可以忽略,貌似是因为我有一些支持加速的指令没有使用

  MatMul:节点名 0:第0个输出

  shape:维度  1表示一位数组长度1

  dtype:数据类型 为float32

  [[11.]]计算结果

posted @ 2018-10-31 12:39  没有昵称的小菜鸟  阅读(829)  评论(0编辑  收藏  举报