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.]]计算结果

转载于:https://www.cnblogs.com/yang295513/p/9882355.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值