Solved ECE4880J Homework 2: Python Programming

$30.00

Original Work ?
Category: Tags: , , You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

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