Back
ExamFull examExam paper only

06 07 2023 E T LAB

Full exam for Numerical Analysis for Machine Learning in the Mathematical Engineering degree programme at Politecnico di Milano. The document covers: Course: Numerical Analysis for Machine Learning Prof. E. Miglio - July 6th 2023 Duration of the exam: 2.5 hours. Exercise 1 Consider the picture of the Duomo di Milano given in file duomo.jpg. import matplotlib.pyplot as plt import numpy as np from matplotlib.image import imread

Numerical Analysis for Machine LearningFull exam

Document information

What's included in this study material

Full exam for Numerical Analysis for Machine Learning in the Mathematical Engineering degree programme at Politecnico di Milano. The document covers: Course: Numerical Analysis for Machine Learning Prof. E. Miglio - July 6th 2023 Duration of the exam: 2.5 hours. Exercise 1 Consider the picture of the Duomo di Milano given in file duomo.jpg. import matplotlib.pyplot as plt import numpy as np from matplotlib.image import imread

Import quality: text was extracted directly from the original document.

Extracted content from the document

Representative passages recognised in different parts of the material. The full extracted text remains available to search, while this compact preview makes the page easier to read.

Page 1

Course: Numerical Analysis for Machine Learning Prof. E. Miglio - July 6th 2023 Duration of the exam: 2.5 hours. Exercise 1 Consider the picture of the Duomo di Milano given in file duomo.jpg. import matplotlib.pyplot as plt import numpy as np from matplotlib.image import imread image_path = 'duomo.jpg' img = imread(image_path) A = np.mean(np.array(img, dtype = np.float64)/255, axis = -1) plt.imshow(A, cmap = 'gray') plt.axis('off') A.shape 1. Compute the SVD associated with the picture, by using the standard algorithm, that gives the exact (up to round-off errors) decomposition. Then, plot the trend w.r.t. i of the singular values σi . Then, repeat the computation by considering the randomized SVD algorithm of rank k = 25, 50, 100, 200 and 400 . Plot the approximate singular values together with the exact singular values. Comment what you see. 2. We now want to compress the image. • Use the exact SVD to perform image compression for rank k = 25 , 50, 100, 200 and 400. Plot the compressed image and compute the reconstruction error as a function of k (use the matrix p-norm with p = 2). • Repeat the same exercise by using the randomized SVD algorithm. • Repeat the same exercise by using the randomized SVD algorithm with a +50% oversampling, that is by increasing by 50% the number of columns in the matrix random P (round the quantity 1.5k to the closest integer). • Finally, plot the trend of the reconstruction error of the dataset as a function of k in the three cases. Comment on the results. 3. Evaluate the time needed to compute the SVD with the three approaches (SVD, randomized SVD, ran- domized SVD with oversampling) in the case k = 200. Exercise 2 Consider the following function (where x = (x, y)) f(x) = 5x2 − 6xy + 5y2 + 4x + 4y (1) 1. Plot the function. 2. Compute…

Preview

First page of the document.

First page: 06 07 2023 E T LAB