Starting from:

$35

Homework 2: Python Programming

ECE4880J: Computer Vision 
Homework 2: Python Programming

Instruction
• This homework is due at 11:59:59 p.m. on ** May 30th, 2022.
• The write-up must be an electronic version edited by LATEX using this template and submitted in pdf format.
• Please DO NOT rename python files and their functions. Just fill it.
• The overall submission should be a .zip file named by xxx(student id)-xxx(name)-Assignment2.zip
Python Environment. We are using Python 3.7 for this course. We will use the following packages
in this course: Numpy, SciPy, Matplotlib, Pytorch.
Q1. Welcome to Python [20 points]
Use Python to achieve the following functionality. Given an array of integers array and an integer
goal, return indices of the two numbers such that they add up to goal. We assume that each pair
of input array and goal has one and only one solution, and you cannot use the same element twice.
Please return the answer in an increasing order.
Example 1:
• Input: array = [2,2], goal = 4
• Output: [0,1]
• Explanation: Because array[0] + array[1] = 4, we return [0, 1].
Example 2:
• Input: array = [2,3,11,15], goal = 5
• Output: [0,1]
• Explanation: Because array[0] + array[1] = 5, we return [0, 1].
Submission Format. Please fill the AddUp function and submit AddUp.py.
Q2. Numpy Crash [40 points]
The aim is to guide you to know the functionality of Numpy.
Installation. Please install Numpy and show your Numpy version in a screenshot.
Task. Please solve 20 problems in numpy.py. Many only need one-line code.
X-1
Submission Format. Please submit your filled numpy.py. Show your screenshot of Numpy version
in the write-up.
Q3. SciPy Crash [10 points]
The aim is to guide you to know the functionality of SciPy.
Installation. Please install SciPy and show your SciPy version in a screenshot.
Task. Please solve 5 problems in scipy.py. Many only need one-line code.
Submission Format. Please submit your filled scipy.py. Show your screenshot of Scipy version in
the write-up.
Q4. Matplotlib Crash [10 points]
The aim is to guide you to know the functionality of Matplotlib.
Installation. Please install Matplotlib and show your Matplotlib version in a screenshot.
Task. Please solve 5 plotting tasks in matplotlib.py.
Submission Format. Please submit your filled matplotlib.py. Show your screenshot of Matplotlib
version and results of function w1-w5 in the write-up.
Q5. Introduction to Pytorch [20 points]
The aim is to guide you to know the functionality of Pytorch.
Installation. Please install Pytorch and show your Pytorch version in a screenshot.
Task. Please follow the instruction and fill in blanks in pytorch.py and complete your first convolutional neural network to handle image classification.
• Read the demo code and fill in the blank noted by """ xxx here """ in pytorch.py
• Vary the training epoch as 1, 2, 4, 8, 16 and plot the accuracy of the “plane” category as a
function of the training epoch.
• Vary the learning rate as [10−5
, 10−4
, 10−3
, 10−2
, 10−1
, 1] and plot the accuracy of the “ship”
category as a function of the learning rate.
• Let’s try another loss function: Mean Squared Error(MSE loss). Compare the performances.
Submission Format. Please submit your filled pytorch.py. Show your screenshot of Pytorch
version in the write-up. Write and analyze your experiment results of above tasks in the write-up.
X-2

More products