Python代写 | CS 542: Machine Learning Problem Set 5

本次Python代写是处理图像并恢复图像的清晰度

CS 542: Machine Learning Summer 2020
Problem Set 5
Lecturer: Prof. Peter Chin Due: June 30, 2020
 Please submit your solutions for the written questions (either type up your answers or scan your
handwritten solution) in a single PDF on Gradescope under the assignment named ”PS5” by
23:59PM on the due date. In your PDF submission for written questions, make sure you have a
single PDF with SIX pages in total as specified in the problem prompts below.
 Submit your programming assignment in a separate assignment named ”PS5 Programming” by
the same due date in a zip file.
 Late policy: there will be a penalty of 10% per day, up to TWO days late. After that no credit
will be given. The written part and programming part are considered as a whole when calculating
late penalties.
1. (40 points) Written Problems
(a) (10 points, Page 1 & 2) Bishop 8.3
(b) (10 points, Page 3 & 4) Bishop 8.4
(c) (10 points, Page 5) Bishop 8.11
(d) (10 points, Page 6) Bishop 8.14
2. (60 points) Programming
(a) (30 points)
(a) Clean image (to restore) (b) Noise contaminated image (c) MRF
The goal of this problem is to recover the clean image (a) from a noisy input (b). Of
course, we cannot recover (a) exactly since information has been lost in the noise. The
graphical model we use is a pairwise MRF as shown in (c). A pixel has four neighbors.
We are going to use Markov Random Frields (MRFs) to model the distribution of natural images and restore the clean image given an noisy input image.
Observed image yi ∈ {−1, +1}, and i = 1, · · · , D indexes pixels in the lattice. The
5-1
original noise free image is xi ∈ {−1, +1}. The noisy image yi
is obtained by randomly
flipping the sign of pixels with some probability.
There are two types of cliques in this MRF. For {xi
, yi}, we define the energy function as
−ηxiyi (η > 0). Lower energy is achieved when xi and yi have the same sign and a higher
energy when they have the opposite sign. For a pair of variables {xi
, xj} where i and
j are indices of neighboring pixels, we want the energy to be lower when the same sign
than when they have opposite sign. So the energy function is −βxixj (β > 0). Lastly,
we have an energy term hxi
for each pixel i to bias the model towards one particular
sign (either + or −).
The final energy function for the model takes the form
E(x, y) = h
X
i
xi − β
X
{i,j}
xixj − η
X
i
xiyi
which defines a joint distribution over x and y given by
p(x, y) = 1
Z
exp{−E(x, y)}
Now implement Coordinate-descent algorithm as below on this:
1. Initialize {xi} (xi = yi)
2. Loop over {xi}. For each xi
, fix the neighborhood and see whether −xi would
decrease the energy. If so, then flip xi
; otherwise, continue.
3. Stop when no changes can be made for x.
Now make some initial guess for the parameters h, β, η so that the above algorithm
converges and then adjust them till you can get up to 96% recovery or better. Record
your parameter values and the number of iterations when you acheived this recovery.
Save the recovered image and submit it along with your code. The clean image and
noisy image are included: Bayes.png, Bayes-noise.png
(b) (30 points)
The goal of this problem is to once again recover the clean image (a) from a noisy
input (b), now in the famous picture of Lena, which is used to benchmark many image
processing algorithms. Of course, we cannot recover (a) exactly since information has
been lost in the noise. The graphical model we use is a pairwise MRF as shown in (c).
A pixel has four neighbors.
The model we are going to use is a simple extension of the chain model we discussed
on the class. A sample code for the message passing algorithm on a chain is included :
ChainMessagePassing.ipynb. Note that the sample code is a sum-product algorithm,
which needs to be changed for max-sum algorithm. The clean image and noisy image
are included: Lena.png, Lena-noise.png
2
(a) Clean image (to restore) (b) Noise contaminated image (c) MRF
Our graphical model is a simple pairwise MRF defined as
p(X|Y, λd, λd) = 1
Z
exp{−λd
X
i
ρ(xi − yi) − λs
X
(i,j)∈ε
ρ(xi − xj )}
where X = {xi} is the set of all the pixels in the image to restore, Y = {yi} denotes the
input noisy image, i indexes the image lattice, ε is the set of all the edges (only adjacent
pixels are considered), λd and λs are coefficients weighing the data term and smoothness
term, respectively. ρ(·) is a penalty function. You can use ρ(z) = |z| (L1 norm) and
ρ(z) = z
2
(L2 norm).
Use the max-product (or max-sum) algorithm to find the MAP solution for X. Treat
the number of state for each pixel as a parameter. Start from a small number such as
32, and then increase it to 64, 128, or 256. Try both L1 and L2 norms. You may also
play with λd and λs to see which combination gives the best restoration result.
3


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:itcsdx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论