dragen1860 / deep-learning-with-tensorflow-book Goto Github PK
View Code? Open in Web Editor NEW深度学习入门开源书,基于TensorFlow 2.0案例实战。Open source Deep Learning book, based on TensorFlow 2.0 framework.
Home Page: http://www.ai101edu.com
深度学习入门开源书,基于TensorFlow 2.0案例实战。Open source Deep Learning book, based on TensorFlow 2.0 framework.
Home Page: http://www.ai101edu.com
少了optimizer = optimizers.Adam(lr=0.01)
导致:
optimizer.apply_gradients(zip(grads, network.trainable_variables))
出错,没有定义optimizer
第37页,2.2节中,"考虑3维函数𝑧 = 𝑓(𝑥, 𝑦),函数对自变量𝑥的偏导数记为𝜕𝑧/𝜕𝑥,函数对自变量𝑥的偏导数记为𝜕𝑧/𝜕𝑦",其中第二个x应为y。
import tensorflow as tf
a = tf.constant(1.)
b = tf.constant(2.)
c = tf.constant(3.)
w = tf.constant(4.)
with tf.GradientTape() as tape:# 构建梯度环境
tape.watch([w]) # 将 w 加入梯度跟踪列表
y = a * w**2 + b * w + c
[dy_dw] = tape.gradient(y, [w])
print(dy_dw) # 打印出导数
tf.Tensor(10.0, shape=(), dtype=float32)
最后一行
tf.Tensor(10.0, shape=(), dtype=float32)
中,这本应是一个输出,但是没有特殊标明,也没有和前面的代码之间空一行,希望可以标明一下。
本人属于零基础学习深度学习,所以对MNIST等都没有认识。通过互联网搜索了写MNIST的基础知识,也尝试了利用NumPy读取MNIST集合中的图片等。
建议增加例程,通过NumPy来读取image和label并保存到指定路径。
如果可以的话,我可以将自己写的例子同步到您的代码中。
谢谢。
老师您好,刚刚听完您的视频教程,是我感觉讲的最好的一位,非常感谢。
由于现在tf2.0正式版已经发布,我安装的是正式版,按照您给出的代码(如下)中的方式屏蔽warning,似乎还会有一部分warning出现(如图)。
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
我查阅了一些网站,发现在正式版tf2.0中,应该将屏蔽代码调整至tf的上方,warning就彻底没有了,不过对于代码运行无关紧要,算是个小疑问吧,再次感谢。
最终顺序:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import datasets
点击“New Issue”就可以发帖啦,一般1~3天之内回复。大家可以自由交流。
在第37页的末尾段,第二行,第二句应该是函数对y的偏导数为(dz/dy),书中前后都是x。
原文”需要注意的是,TensorFlow 的布尔类型和Python语言的布尔类型并不对等,不能通用”,该局话最好加上,可以进行比较,且下面的例子是错误的。tf.constant(True) == True
的结果就是 True
。
P15 Line5 GooleNet->GoogleNet
P35 倒数第4行 现象神经元->线性神经元
P37 倒数第5行 函数对自变量x的偏导数->函数对自变量y的偏导数
P38 倒数第7行 应用速学->应用数学
P49 Line1 便签->标签
P59 倒数11行 如果采用tf.float32 精度保存𝜋->如果采用tf.float64 精度保存𝜋
P64 Line18 正太分布->正态分布
P64 Line9 制定->指定
P71 Line4 随即分布->随机分布
p79 out[74]
there is a small mistake of this picture its dims should be [1,28,28,1], but there is a [28,28,1]
就是酱紫
x= x[:, tf.newaxis, tf.newaxis, :]
In [100]:
a = tf.random.normal([4,3,23,32])
第三个应该是28,不是23
原文:
那么 ReLU 函数可以实现为:
def relu(x):
return tf.minimum(x,0.) # 下限幅为 0 即可
改为:minimum->maximum
第七排的正太分布,字打错了,应该是正态分布
2.2优化方法,第4页,图2.5下方,出现两次“函数对自变量x的偏导数”,第二次应该是“函数对自变量y的偏导数”吧?
第二章回归问题部分,MSE是均方误差,与均方差是不同的概念。均方误差比较的是预测值和真实值,而均方差比较的是数值和自己的均值(期望)
书中第231页,13.1节,“……而鉴别器D 通过学习真钞和生成器G 长生的假钞来掌握钞票的鉴别方法。”“长生”应为“产生”。
第67页:
fc = layers.Dense(3)
应修改为:
fc=tf.keras.layers.Dense(3)
第68页:
fc = layers.Dense(3)
应修改为:fc =tf.keras.layers.Dense(3)
从“比如张量a shape:[4,3,28,32] ”开始,后面部分的shape没对上
tf1.py的源码中使用了assert。
assert tf.version.startswith('1.')
而我安装的是tf2,pdf教程中也写的是使用tf2。所以导致这个assert错误。代码应该改为如下:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
assert tf.version.startswith('2.')
Page 10 最后一句 "不再敖述" 应为 "不再赘述"
您好,您写得非常好,非常容易明白,但是PDF没有书签,不方便查找翻阅,请问可以增加一版有书签的PDF吗?谢谢了
你好,我在使用K临近算法来实现酒的分类 ,但时遇到了一个配置问题,非常感谢您能帮我解答
ModuleNotFoundError: No module named 'joblib'
以下时我的代码
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 from sklearn.datasets import load_wine
2 win_dataset=load_wine()
3 print('\n\n\n')
4 print("the result is")
5 print("红酒中的数据:\n{}".format(wine_dataset.keys()))
~\AppData\Roaming\Python\Python37\site-packages\sklearn_init_.py in
74 else:
75 from . import __check_build
---> 76 from .base import clone
77 from .utils._show_versions import show_versions
78
~\AppData\Roaming\Python\Python37\site-packages\sklearn\base.py in
14
15 from . import version
---> 16 from .utils import _IS_32BIT
17
18 _DEFAULT_TAGS = {
~\AppData\Roaming\Python\Python37\site-packages\sklearn\utils_init_.py in
15 from .murmurhash import murmurhash3_32
16 from .class_weight import compute_class_weight, compute_sample_weight
---> 17 from . import _joblib
18 from ..exceptions import DataConversionWarning
19 from .deprecation import deprecated
~\AppData\Roaming\Python\Python37\site-packages\sklearn\utils_joblib.py in
6 # joblib imports may raise DeprecationWarning on certain Python
7 # versions
----> 8 import joblib
9 from joblib import logger
10 from joblib import dump, load
ModuleNotFoundError: No module named 'joblib'
tf.keras.experimental.export_saved_model(network, path) 这种方式已经过时了,是否可以替换成 model.save(path) 或者tf.saved_model.save(model, paht)方式
train_db = train_db.repeat(20) # 数据集跌打20遍才终止
应该是迭代
书12.5VAE实战中
本节我们基于 VAE 模型实战 Fashion MNIST 图片的重建与生成。如图 12.12 所示,输
入为 Fashion MNIST 图片向量,经过 3 个全连接层后得到隐向量𝐳的均值与方差,分别用 2
个输出节点数为 20 的全连接层表示,FC2 的 20 个输出节点表示 20 个特征分布的均值向量μ
,FC3 的 20 个输出节点表示 20 个特征分布的方差向量的𝑙𝑜𝑔值。通过 Reparameterization
trick 采样获得长度为 20 的隐向量𝐳,并通过 FC4/FC5 重建出样本图片。
但是代码里的是
`z_dim = 10
class VAE(keras.Model):
def __init__(self):
super(VAE, self).__init__()
# Encoder
self.fc1 = layers.Dense(128)
self.fc2 = layers.Dense(z_dim) # 均值输出
self.fc3 = layers.Dense(z_dim) # 方差输出
# Decoder
self.fc4 = layers.Dense(128)
self.fc5 = layers.Dense(784)`
另外一处在重建图片那里
`
x = next(iter(test_db))
x = tf.reshape(x, [-1, 784])
x_hat_logits, _, _ = model(x)
x_hat = tf.sigmoid(x_hat_logits)
x_hat = tf.reshape(x_hat, [-1, 28, 28]).numpy() * 255.
x_hat = x_hat.astype(np.uint8)
save_images(x_hat, 'vae_images/rec_epoch%d.png' % epoch)`
4.5.5 4维张量
[b,h,w,c]下面的一行,h/w分布表示特征图的高宽,应该是分别,打错了应该
then pyCharm cannot resolve module tf.keras and report an error:
Cannot find reference 'keras' in 'init.py'
But when running program, everything works well.
i follow this way , but it also didn't work well.
Is there anyways to solve it?
Thanks.
“并用过 MNIST 数据集的测试实战加深读者对
TensorFlow 张量操作的立即”
1.1.3章节中的"基于规则的系统一般会编 写显示的规则逻辑"中的“显示”应为“显式”?
p88
In[100]:
Tensor a should be with shape([4,3,28,32])
第一段,第四句行。激活含水层->激活函数层。
Sent from PPHub
pdf 测试水印可以添加到页眉或者页脚吗?打印的时候有时候会影响打印效果。
函数对自变量𝑥的偏导数记为𝜕𝑧/𝜕𝑥,函数对自变量𝑥的偏导数记为𝜕𝑧/𝜕𝑦,则梯度∇𝑓为向量....
文字段落是否需要两端对齐?我在看第11章的时候看到有些段落是左对齐的,右边就参差不齐了。
书中原文:
通过 TensorFlow 实现如下
import tensorflow as tf创建4 个张量
a = tf.constant(1.)
b = tf.constant(2.)
c = tf.constant(3.)
w = tf.constant(4.)
with tf.GradientTape() as tape:# 构建梯度环境
tape.watch([w]) # 将w 加入梯度跟踪列表构建计算过程
y = a * w**2 + b * w + c
求导
[dy_dw] = tape.gradient(y, [w])
print(dy_dw) # 打印出导数
tf.Tensor(10.0, shape=(), dtype=float32)
最后一行易令人误为程序内容。此行前应加入输出说明
如题,希望能尽快也出一版pytorch的,那就最好了
试版(201911配套视频课程(收费,提供答疑等全方位服务,不喜勿喷):
深度学习与 TensorFlow 入门实战 深度学习与 PyTorch 入门实战
https://study.163.com/course/courseMai
n.htm?share=2&shareId=48000000184
7407&courseId=1209092816&_trace_c
p_k2=9e74eb6f891d47cfaa6f00b5cb
5f617c
https://study.163.com/course/courseMain.htm?share=2&shareId=480000001847407&courseId=1208894818&_trace_c_p_k2_=8d1b10e04bd34d69855bb71da65b05
老师您好,在运行CH15 自定义数据集的时候,出现了如下警告:
iCCP: known incorrect sRGB profile
虽然不影响程序,但是影响了观测训练,希望老师能够帮忙解决
pdf提示已经损坏
如果采用tf.float32 精度保存𝜋,则能获得更高的精度:
应该是tf.float64
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.