欢迎关注天善智能,我们是专注于商业智能BI,人工智能AI,大数据分析与挖掘领域的垂直社区,学习,问答、求职一站式搞定!
对商业智能BI、大数据分析挖掘、机器学习,python,R等数据领域感兴趣的同学加微信:tsaiedu,并注明消息来源,邀请你进入数据爱好者交流群,数据爱好者们都在这儿。
作者简介:
鲁伟:一个数据科学践行者的学习日记。数据挖掘与机器学习,R与Python,理论与实践并行。
个人公众号:数据科学家养成记 (微信ID:louwill12)
配套学习视频教程: 手把手教你用Python 实践深度学习
在笔记7中,笔者和大家一起入门了Tensorflow的基本语法,并举了一些实际的例子进行了说明,终于告别了使用numpy手动搭建的日子。所以我们将继续往下走,看看如何利用Tensorflow搭建神经网络模型。
尽管对于初学者而言使用Tensorflow看起来并不那么习惯,需要各种步骤,但简单来说,Tensorflow搭建模型实际就是两个过程:创建计算图和执行计算图。在 deeplearningai 课程中,NG和他的课程组给我们提供了Signs Dataset(手势)数据集,其中训练集包括1080张64x64像素的手势图片,并给定了 6 种标注,测试集包括120张64x64的手势图片,我们需要对训练集构建神经网络模型然后对测试集给出预测。
![3901436-c0f2c5cbaa614680.png](https://i-blog.csdnimg.cn/blog_migrate/927d1328973e81be47fb1cc5717f5094.webp?x-image-process=image/format,png)
先来简单看一下数据集:
# Loading the datasetX_train_orig, Y_train_orig, X_test_orig, Y_test_orig, classes = load_dataset()# Flatten the training and test imagesX_train_flatten = X_train_orig.reshape(X_train_orig.shape[0], -1).T
X_test_flatten = X_test_orig.reshape(X_test_orig.shape[0], -1).T# Normalize image vectorsX_train = X_train_flatten/255.X_test = X_test_flatten/255.# Convert training and test labels to one hot matricesY_train = convert_to_one_hot(Y_train_orig, 6)
Y_test= convert_to_one_hot(Y_test_orig,6)print("number of training examples = "+ str(X_train.shape[1]))print("number of test examples = "+ str(X_test.shape[1]))print("X_train shape: "+ str(X_train.shape))print("Y_train shape: "+ str(Y_train.shape))print("X_test shape: "+ str(X_