Active Update Demo

Demonstrates using deeplenstronomy in an active learning framework

Introduction

First we'll simulate a dataset for which we may want to update some of the parameters.

We'll use a very basic configuration file for this example:

Great, now make the dataset.

As a reminder of what the make_dataset() function does, let's look at the attributes of the dataset object.

We'll be spending a lot of time looking at update_param, update_param_dist, and regenerate, but for now let's check out the actual image and it's metadata. The dataset size was 1 in the config file, so there will only be one image to look at.

Updating Parameters

Let's take a look at the update_param() function to see how it works.

So let's suppose we want to change num_exposures to 3 and force the source galaxy to be 3 arc sec to the right. From the metadata columns in the above list, create a dictionary with the parameter and new value.

And now just call the update function. You will always need to specify the configuration, so if you want to make the change for all configurations, just run the update function in a loop.

To see if that worked, let's print out the dataset's config_dict, which stores all the info about the dataset.

As you can see the parameters have been updated. Now to regenerate the dataset, let's check out the regenerate() function.

The regenerate function will automatically use the same parameters that were supplied in the original call to deeplenstronomy.make_dataset().

To really convince ourselves that this worked, let's look at the image again.

While it's tough to tell by eye that the num_exposures was updated, we can see the source galaxy has been moved 3 arcseconds to the right. Woohoo!

Next, let's say we want a parameter to be drawn from a distribution, and we want to update the characteristics of that distribution. In this case, we'll use the update_param_dist() function.

So let's suppose that after some analysis we've decided the source galaxy's center_y parameter should be drawn from a uniform distribution on the interval [4, -2].

Again, we can verify that the change was implemented by looking at the configuration dictionary:

Now all that's left to do is regenerate the dataset and check out the results.

Summary

With the ability to update the parameters of a dataset and regenerate it programatically, you should be able to arrive at a finalized dataset through the optimization of a metric of your choice.