吴恩达深度学习课程第一课第二周课程作业

学过吴恩达的Machine Learning课程,现在跟着学深度学习,本来是想付费的,奈何搞半天付款没有成功,没办法只能下载数据集自己搞了。由于门外汉,安装工具软件加上完成作业花了一天时间,其实第二周的作业和机器学习课程基本是一样的,没有什么太大难度,都是初级入门,但是课程视频还是讲了一些之前没有接触过的内容。
课程作业数据集和代码可以到百度云下载:
链接:https://pan.baidu.com/s/1cwd8IE 密码:1xkv

1、作业前环境安装和工具准备

本部分只针对不知道咋自己搭建作业环境的同学,当然大神也不会浏览到我的博客啦 哈哈!
第一步 安装jupyter notebook,安装方法很简单,只要安装了Python和pip工具就可以了
win系统在cmd命令行输入pip install jupyter notebook
安装jupyter notebook
安装后就是启动jupyter notebook,直接在命令窗口输入jupyter notebook即可启动了,由默认浏览器打开。
打开notebook
默认的文件夹是C盘下用户文件夹,可以通过修改配置文件修改默认文件夹,详见http://blog.csdn.net/qq_33039859/article/details/54604533
然后就把数据集和模块文件放到里面去,然后点“New”选择Python新建文件,点击这个文件就可以进行编程了。
编程页面
第二步是安装第三方工具库,本周用到的库有numpy h5py matplotlib PIL scipy ,这些库都可以使用pip工具安装,和上面安装notebook步骤是一样的,不再赘述了。(可以在Python IDLE里面import一下看有没有安装成功)

2、安装包,前面说过了,这几个包主要是科学计算和图片处理用的,具体可以上网搜一下。

import numpy as np
import matplotlib.pyplot as plt
import h5py
import scipy
from PIL import Image
from scipy import ndimage
from lr_utils import load_dataset

3、数据集处理

导入数据,使用课程提供lr_utils模块load_dataset函数

train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dataset()

获得样本数量

m_train=train_set_x_orig.shape[0]
m_test=test_set_x_orig.shape[0]
num_px=train_set_x_orig[0].shape[0]

打印数据集中样本的一些参数,可以直观检查数据规模

print (“Number of training examples: m_train = ” +
str(m_train))
print (“Number of testing examples: m_test = ” + str(m_test))
print (“Height/Width of each image: num_px = ” + str(num_px))
print (“Each image is of size: (” + str(num_px) + “, ” + str(num_px) + “, 3)”)
print (“train_set_x shape: ” + str(train_set_x_orig.shape))
print (“train_set_y shape: ” + str(train_set_y.shape))
print (“test_set_x shape: ” + str(test_set_x_orig.shape))
print (“test_set_y shape: ” + str(test_set_y.shape))

Number of training examples: m_train = 209
Number of testing examples: m_test = 50
Height/Width of each image: num_px = 64
Each image is of size: (64, 64, 3)
train_set_x shape: (209, 64, 64, 3)
train_set_y shape: (
  • 10
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值