吴恩达Coursera深度学习课程 DeepLearning.ai 编程作业——Convolution model:step by step and application (4.1)

该博客详细介绍了Coursera上吴恩达深度学习课程中关于卷积神经网络(CNN)的编程作业。内容涵盖了卷积层(包括零填充、单步卷积和前向传播)、池化层的前向传播、CNN的反向传播,以及在TensorFlow中构建CNN模型的步骤。通过这个作业,读者将能够理解CNN的构建块并实现它们的前向和反向传播。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一.Convolutional Neural Networks: Step by Step

Welcome to Course 4’s first assignment! In this assignment, you will implement convolutional (CONV) and pooling (POOL) layers in numpy, including both forward propagation and (optionally) backward propagation.

Notation:

  • Superscript [ l ] [l] [l] denotes an object of the l t h l^{th} lth layer.

    • Example: a [ 4 ] a^{[4]} a[4] is the 4 t h 4^{th} 4th layer activation. W [ 5 ] W^{[5]} W[5] and b [ 5 ] b^{[5]} b[5] are the 5 t h 5^{th} 5th layer parameters.
  • Superscript ( i ) (i) (i) denotes an object from the i t h i^{th} ith example.

    • Example: x ( i ) x^{(i)} x(i) is the i t h i^{th} ith training example input.
  • Lowerscript i i i denotes the i t h i^{th} ith entry of a vector.

    • Example: a i [ l ] a^{[l]}_i ai[l] denotes the i t h i^{th} ith entry of the activations in layer l l l, assuming this is a fully connected (FC) layer.
  • n H n_H nH, n W n_W nW and n C n_C nC denote respectively the height, width and number of channels of a given layer. If you want to reference a specific layer l l l, you can also write n H [ l ] n_H^{[l]} nH[l], n W [ l ] n_W^{[l]} nW[l], n C [ l ] n_C^{[l]} nC[l].

  • n H p r e v n_{H_{prev}} nHprev, n W p r e v n_{W_{prev}} nWprev and n C p r e v n_{C_{prev}} nCprev denote respectively the height, width and number of channels of the previous layer. If referencing a specific layer l l l, this could also be denoted n H [ l − 1 ] n_H^{[l-1]} nH[l1], n W [ l − 1 ] n_W^{[l-1]} nW[l1], n C [ l − 1 ] n_C^{[l-1]} nC[l1].

We assume that you are already familiar with numpy and/or have completed the previous courses of the specialization. Let’s get started!

1 - Packages

Let’s first import all the packages that you will need during this assignment.

  • numpy is the fundamental package for scientific computing with Python.
  • matplotlib is a library to plot graphs in Python.
  • np.random.seed(1) is used to keep all the random function calls consistent. It will help us grade your work.
import numpy as np
import h5py
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"]=(5.0,4.0)
plt.rcParams["image.interpolation"]='nearest'
plt.rcParams["image.cmap"]='gray'

np.random.seed(1)

2 - Outline of the Assignment

You will be implementing the building blocks of a convolutional neural network! Each function you will implement will have detailed instructions that will walk you through the steps needed:

  • Convolution functions, including:
    • Zero Padding
    • Convolve window
    • Convolution forward
    • Convolution backward (optional)
  • Pooling functions, including:
    • Pooling forward
    • Create mask
    • Distribute value
    • Pooling backward (optional)

This notebook will ask you to implement these functions from scratch in numpy. In the next notebook, you will use the TensorFlow equivalents of these functions to build the following model:

这里写图片描述

Note that for every forward function, there is its corresponding backward equivalent. Hence, at every step of your forward module you will store some parameters in a cache. These parameters are used to compute gradients during backpropagation.

3 - Convolutional Neural Networks

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值