# Confused with Programming assignment

**URL:** <https://dlai.staged-by-discourse.com/t/confused-with-programming-assignment/746570>\
**Category:** Neural Networks and Deep Learning\
**Tags:** week-module-2, coursera-platform\
**Created:** [January 5, 2025, 7:55pm UTC](https://dlai.staged-by-discourse.com/t/confused-with-programming-assignment/746570 "2025-01-05T19:55:48Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Kic](https://sea1.discourse-cdn.com/dlaistaging/user_avatar/dlai.staged-by-discourse.com/kic/32/76339_2.png) [@Kic](https://dlai.staged-by-discourse.com/u/Kic)\
**Post date:** [January 5, 2025, 10:27pm UTC](https://dlai.staged-by-discourse.com/t/confused-with-programming-assignment/746570/5 "2025-01-05T22:27:10Z")

</div>

Hi @reinhardt_scott,  
In regard to your question 1, I am referencing the instruction below:

## 2 - Overview of the Problem set

**Problem Statement** : You are given a dataset (“data.h5”) containing:

```auto
- a training set of m_train images labeled as cat (y=1) or non-cat (y=0)
- a test set of m_test images labeled as cat or non-cat
- each image is of shape (num_px, num_px, 3) where 3 is for the 3 channels (RGB). Thus, each image is square (height = num_px) and (width = num_px).

```

Here, num\_px is number of pixels in a image. As each image has the same number of pixel for the width and height, so it is a square image. In this exercise, both the training set and test set use images of the same size,  
whether num-px is taken from the training set or test set would still give you the correct answer. However, it would be more appropriate to get num\_px from the training set. Similarly, it doesn’t matter if you get the num\_px from train\_set\_x\_orig.shape[1] or train\_set\_x\_orig.shape[2].

For your second question, what it means is that you need to change the array representation of the image from an array of size (num\_px, num\_px,3) into a single vector of size (num\_px \* num\_px, 1), here the ‘\*’ is the multiplication operator.

To do that, you are given a hind to use the X.reshape() function. Here, the X represent the dataset you are interested in. So if you want to flatten the training dataset, this is what it would look like:  
train\_set\_x\_flatten =train\_set\_x\_orig.reshape(train\_set\_x\_orig.shape[0], -1).T  
You may find this thread helpful: [W 2 A1 | Exercise 2 : X\_flatten = X.reshape(X.shape[0], -1).T? - Deep Learning Specialization / Neural Networks and Deep Learning - DeepLearning.AI](http://dlai.staged-by-discourse.com/t/w-2-a1-exercise-2-x-flatten-x-reshape-x-shape-0-1-t/205663)

---

_[View the full topic](https://dlai.staged-by-discourse.com/t/confused-with-programming-assignment/746570)._
