您当前的位置: 首页 >  tensorflow

Better Bench

暂无认证

  • 0浏览

    0关注

    695博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

【北京大学】2 TensorFlow1.x的张量、计算图、会话

Better Bench 发布时间:2020-12-19 11:08:30 ,浏览量:0

1 张量

张量(tensor):多维数组(列表) 阶:表示张量的维度 在这里插入图片描述

数据类型:tf.float32 tf.int32…

#coding:utf-8
import tensorflow as tf       #引入模块 
a = tf.constant([1.0, 2.0])   #定义一个张量等于[1.0,2.0] 
b = tf.constant([3.0, 4.0])   #定义一个张量等于[3.0,4.0] 
result = a+b                  #实现 a 加 b 的加法 
print result               #打印出结果 

在这里插入图片描述

为了使得linux系统更方便使用vim。更改vim配置

vim ~/.vimrc #写入以下内容 set ts = 4 set nu

2 计算图

计算图(Graph):搭建神经网络的计算过程,只搭建 在这里插入图片描述

#coding=utf-8
import tensorflow as tf
x = tf.constant([[1.0, 2.0]])
w = tf.constant([[3.0], [4.0]])
y = tf.matmul(x,w)#计算图(Graph):
print y
3 会话

会话(session):执行计算图中节点计算

#coding=utf-8
import tensorflow as tf
x = tf.constant([[1.0, 2.0]])
w = tf.constant([[3.0], [4.0]])
y = tf.matmul(x,w)#计算图(Graph):
print y
with tf.Session() as sess:
    print sess.run(y)# 执行计算图中的节点运算。
相关笔记

以下所有源码以及更详细PDF笔记请在github下载 TensorFolwNotebook-from-Peking-University

  1. 【北京大学】1 TensorFlow1.x中Python基础知识
  2. 【北京大学】2 TensorFlow1.x的张量、计算图、会话
  3. 【北京大学】3 TensorFlow1.x的前向传播推导与实现
  4. 【北京大学】4 TensorFlow1.x的反向传播推导与实现
  5. 【北京大学】5 TensorFlow1.x的损失函数和交叉熵举例讲解及实现
  6. 【北京大学】6 TensorFlow1.x的学习率、滑动平均和正则化实例及实现
  7. 【北京大学】7 TensorFlow1.x的神经网络模块设计思想举例及实现
  8. 【北京大学】8 TensorFlow1.x的Mnist数据集实例实现
  9. 【北京大学】9 TensorFlow1.x的实现自定义Mnist数据集
  10. 【北京大学】10 TensorFlow1.x的卷积神经网络(CNN)相关基础知识
  11. 【北京大学】11 TensorFlow1.x的卷积神经网络模型Lenet5实现
  12. 【北京大学】12 TensorFlow1.x的卷积神经网络模型VGGNet实现
  13. 【北京大学】13 TensorFlow1.x的项目实战之手写英文体识别OCR技术
  14. 【北京大学】14 TensorFlow1.x的二值神经网络实现MNIST数据集手写数字识别
  15. 【北京大学】15 TensorFlow1.x的项目实战之人脸表情识别
  16. 【北京大学】16 TensorFlow1.x的项目实战之图像风格融合与快速迁移
关注
打赏
1665674626
查看更多评论
立即登录/注册

微信扫码登录

0.0462s