← Indietro
EsameEsame completoTesto d’esame

07 02 2023 E T LAB

Esame completo di Numerical Analysis for Machine Learning per il corso di Mathematical Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Numerical Analysis for Machine LearningEsame completo

Informazioni sul documento

Cosa trovi in questo materiale

Esame completo di Numerical Analysis for Machine Learning per il corso di Mathematical Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Qualità dell’importazione: il testo è stato estratto direttamente dal documento originale.

Contenuti estratti dal documento

Passaggi rappresentativi riconosciuti nelle diverse parti del materiale. Il testo completo resta presente nella pagina per la ricerca, mentre l’anteprima compatta rende più semplice la lettura.

Pagina 1

Course: Numerical Analysis for Machine Learning Prof. E. Miglio - February 7th 2023 Duration of the exam: 2.5 hours. Exercise 1 Load the picture of Politecnico’s facade polimi compressed.jpg. Please notice that the RGB object is list of three matrices, each one corresponding to a different ”channel” (i.e. red, greed, or blue). import numpy as np import matplotlib.pyplot as plt from matplotlib.image import imread image_path = 'polimi_compress.jpg' img = imread(image_path) img_RGB = [np.array(img[:,:,i], dtype = np.float64)/255 for i in range(3)] def plot_image(RGB, ax = None): if ax is None: _, ax = plt.subplots(1,1, figsize = (12,5)) ax.imshow(np.clip(np.stack(RGB, axis = 2),0,1)) plt.axis('off') plot_image(img_RGB) Now, randomly replace 70% of the pixels with random colors. damage_fraction = 0.7 np.random.seed(0) mask_remove = np.random.choice(a=[True, False], size=(img.shape[0],img.shape[1]), \ p=[damage_fraction, 1-damage_fraction]) mask_keep = np.logical_not(mask_remove) img_damaged_RGB = [img_RGB[i].copy() for i in range(3)] for i in range(3): img_damaged_RGB[i][mask_remove] = np.random.rand(np.sum(mask_remove)) 1. Display the damaged image. 2. Implement the singular value truncation (SVT) algorithm to reconstruct the picture fromimg damaged RGB. (Hint: apply the algorithm independently to each channel.) 3. Try to optimize by trial and error the threshold on the singular values. Run the algorithm for 20 iterations and plot the resulting image against the original and the damaged one. 4. Comment on the impact of the threshold on the results. Exercise 2 Explain how a perceptron works and how to apply the gradient descent method to optimize the parameters of the perceptron. Consider the following set of data x1 = (2, −1),y1 = 1, x2 = (−1, 1),y2 = 0, x3 = (2, 0.5),y3…

Anteprima

Prima pagina del documento.

Prima pagina: 07 02 2023 E T LAB