Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

E19: Numerical Methods for Engineering Applications Spring 2016 - PROJECT 4

Project: Benchmarking gradient-free optimizers

OVERVIEW

In this project, you will investigate the effectiveness of several gradient-free optimization techniques in solving a particular optimization problem: lossy image compression.

BACKGROUND

For this project, we will approximate a grayscale image using a sum of k 2D Gaussian functions. Each Gaussian function has six parameters influencing its shape, size, location, rotation, and intensity. Therefore, the overall image may be approximated by 6k numbers. Contrast this to the "traditional" method of representing a w-by-h image as a list of pixel intensities - if our Gaussian functions approximate the image well, and if 6k << w x h, we have effectively compressed the image by representing it with a much smaller list of numbers.

Our objective function f(x) for this optimization problem will be the sum of squared differences in pixel values between the original image and the Gaussian reconstruction. We will investigate how this objective is minimized by three different optimization methods: greedy hill climbing2, the Nelder-Mead method (which we discussed in class), and finally, Powell's method (which you will research on your own). Furthermore, since the objective function allows us to select different values of k, we can investigate how each method's performance scales with problem size.

Your goal is to generate a number of random intial x vectors for a variety of values of k, and test the performance of all of the methods on each vector. FYI, the function scipy.optimize.minimize() can be used to run either Nelder-Mead or Powell by passing in the appropriate method parameter.

DISCLAIMER

Real-life image compression (e.g. JPEG) doesn't work this way - it's much cleverer. We are just hacking together a silly representation of a compressed image that lets us play with optimizers!

TASKS

Download the starter code from the course website. It contains a very useful base for generating and visualizing sums of Gaussian functions as images.

Implement the objective function. Look at the portion of the starter code which maps the vector of parameters x to the resulting objective function value (on lines 167-174).

Your first task should be to wrap up all of the variables besides x (e.g. xmesh, ymesh, target) into a Python lambda object f which accepts x as input and provides the objective function value as output. Remember, since we are using lambdas, there is no need to define any new functions with the def keyword to define a function, or to use global variables anywhere!

Implement a mutation function, and run the hill climbing algorithm. Now create a lambda object called mutate which takes single parameter vector x as input and which outputs a perturbed version by calling the perturb_params function (your lambda should wrap up the w and h parameters required by this function).

Once you have f and mutate, you should be able to do the hill climbing method by passing these lambdas to the greedy_random_hillclimbing function. Try running it on a smallish (k = 5) parameter vector for a small number of iterations (perhaps 100 or so). Although the results will not substantially resemble the input image, you should at least be able to verify that the objective function is decreased by this function.

Benchmark the three methods on the image problem for k = 8, 16, and 32. For each value of k, test each algorithm 10 times on a new initial randomly generated vector. You should limit the number of function evaluations to 10,000. For hill climbing, this is passed in as a parameter to the function; for the others, you should provide options=dict(maxfev=10000) to the scipy.optimize.minimize function.

The results of your benchmarks should be summarized by including all of the following in your PDF write up:

  • a set of bar graphs (with standard error bars) showing the mean runtimes of each optimization method as k is varied
  • a set of bar graphs (with standard error bars) summarizing the objective function values obtained by each method as k is varied
  • a set of representative images of the best and worst outputs of each optimization method (you can use matplotlib.pyplot.savefig to save figures)

Go further Take your lab a bit further by trying out one of the following ideas (or approach me if you are interested in coming up with your own idea):

  • Research one of the other methods implemented by scipy.optimize.minimize and tell me what you discovered.
  • Try out these optimizers on your own Engineering-inspired unconstrained multivariable minimization problem.
  • Try to modify the program to compress a color image (see me for help).

WHAT TO TURN IN

You should submit all of your source code along with a PDF write-up containing your plots and answers to these questions (a few sentences on each should suffice).

  • Which optimization method acheieves the best performance, and why? You may find it instructive to flip through the first few slides at http://informatik.unibas.ch/fileadmin/Lectures/HS2013/CS253/PowellAndDP1.pdf to learn a bit about Powell's method in order to explain the results.
  • Which method is slowest? Fastest? Explain why you think that might be the case.
  • Would it be theoretically possible to use a non-linear least-squares solver such as the Gauss-Newton method to solve this image compression problem? If so, why might we still prefer to use a method like Powell or Nelder-Mead? If not, why not?

Attachment:- Assignment.zip

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91844562

Have any Question?


Related Questions in Computer Engineering

Suppose pointers are 4 bytes long and keys are 12 bytes

Suppose pointers are 4 bytes long, and keys are 12 bytes long. How many keys and pointers will a block of 16,384 bytes have?

Suppose that you sample 59 high school baseball pitchers in

Suppose that you sample 59 high school baseball pitchers in one county and find that they have a mean fastball pitching speed of 80.00 miles per hour (mph) with a standard deviation of 4.98 mph. Find a 95% confidence int ...

What are content management systems cms describe the

What are Content Management Systems (CMS). Describe the challenges in implementing and maintaining CMS. Can internet search engines be considered as Content Management Systems - explain your answer.

How to design a java program that reads a sentence say s

How to design a Java program that reads a sentence, say s, consisting of lower-case words with .nextLine() method, identifies the words using .indexOf() and .substring() methods and saves them in String variables. Then t ...

Case study - social media research facilitytaskthis

Case study - Social Media Research facility Task This assignment follows from the case study used in Assessment . For the same case study, complete the following tasks by creating the following: WBS first using indented ...

A video movie store owner finds that 30 of the customers

A video movie store owner finds that 30% of the customers entering the store ask an assistant for help and that 20% of the customers make a purchase before leaving. It is also found that 15% of all customers both ask for ...

How do you calculate the number of peaks and mass when

How do you calculate the number of peaks and mass when Bromine with two isotopes and phosphate with one isotope are put through a mass spectrometer? The formula is PBr3

Question subject digital securitybriefly explain how

Question : Subject: Digital security Briefly explain how Android 3.0 and later versions encrypt file and user data, and how encryption keys are derived. The response must be typed, single spaced, must be in times new rom ...

A for which hypervisors does kali linux offer custom

a. For which hypervisors does Kali Linux offer custom images? What tools must be added to a VirtualBox Kali Linux VM to provide proper integration with the host machine? b. What hypervisor comes already installed in Kali ...

The power of the market - 1990watch and discuss the video

The Power of the Market - 1990 Watch and discuss the video - The Power of the Market http://www.freetochoose.tv/program.php?id=ftc1990_1&series=ftc90 Links to an external site. By  discuss  I mean: Overall, what did you ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As