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