Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying COMBO to own dataset #4

Open
nataliebarcickikas opened this issue Mar 10, 2020 · 12 comments
Open

Applying COMBO to own dataset #4

nataliebarcickikas opened this issue Mar 10, 2020 · 12 comments

Comments

@nataliebarcickikas
Copy link

I would like to try your method on my own dataset and own objective function. There isn't too much with respect to documentation about the format and structure to do this in the repo. Could you please provide some more details on how to set this up?

@ChangYong-Oh
Copy link
Collaborator

ChangYong-Oh commented Mar 10, 2020 via email

@nataliebarcickikas
Copy link
Author

Where are the number of categorical variables accounted for? In the case of the pest control problem, would that correspond to PESTCONTROL_N_STAGES = 5 in the following line? It is a little unclear because there is both a notion of stations and stages in your paper for this application.

self.n_vertices = np.array([PESTCONTROL_N_CHOICE] *PESTCONTROL_N_STAGES)

@ChangYong-Oh
Copy link
Collaborator

ChangYong-Oh commented Mar 11, 2020 via email

@nataliebarcicki
Copy link

I am still working with your code and would like to modify the initialization of the experiment. Specifically, I would like to initialize everything to "on" i.e. vector of all 1s, and then explore the input space from there, rather than randomly switching some nodes on and some off at the beginning. I assume I control this in "experiment_configuration.py". I wrote a new function below, but this constantly generates all "on" vectors during the optimization, rather than solely the first input as all "on". Can you point me as to how to modify the starting point? I think my confusion is stemming from my lack of understanding of the argument "n_points" and the corresponding for-loop.

def allon_init_points(n_vertices, n_points, random_seed=None):
    """

    :param n_vertices: 1D array
    :param n_points:
    :param random_seed:
    :return:
    """
    if random_seed is not None:
        rng_state = torch.get_rng_state()
        torch.manual_seed(random_seed)
    init_points = torch.empty(0).long()
    for _ in range(n_points):
        init_points = torch.cat([init_points, torch.cat([torch.randint(1, 2, (1, 1)) for elm in n_vertices], dim=1)], dim=0) % silly way to make it a vecotr of all 1s
    if random_seed is not None:
        torch.set_rng_state(rng_state)
    return init_points

This function then gets called in my class definition as follows:

self.suggested_init = torch.empty(0).long()
 self.suggested_init = torch.cat([self.suggested_init, allon_init_points(self.n_vertices, 20-self.suggested_init.size(0), random_seed).long()], dim=0)

But I don't understand the code entirely.

@ChangYong-Oh
Copy link
Collaborator

ChangYong-Oh commented May 11, 2020 via email

@nataliebarcicki
Copy link

nataliebarcicki commented May 11, 2020

Thanks for your quick response. I think you misunderstood.

Let's say I have 10 categorical variables. I want them all to take value '1' initially, and then for the Bayesian optimization to explore the space from there. So it would be:
Step 0: [1 1 1 1 1 1 1 1 1 1]
Step 1: [1 0 1 1 1 0 1 1 1 0] (For example)
Step 2: [1 1 0 1 1 1 1 0 0 1]
and so on...

Would it be simply adding the line:
self.suggested_init[0, 1] = 1 (making ALL categorical variable '1') after

self.suggested_init = torch.cat([self.suggested_init, sample_init_points(self.n_vertices, 20 - self.suggested_init.size(0), random_seed_pair[1]).long()], dim=0)

I guess part of my confusion stems from the fact that I don't understand why we specify all the initializations anyway - shouldn't the search be guided by the acquisition function? I want the algorithm to "learn" from the initial starting point of all 1s and be more inclined to staying at all 1s, since I know that the global optimum lies close to all 1s in my case. Shouldn't the acquisition function guide the next set of points to explore instead of the user?

@ChangYong-Oh
Copy link
Collaborator

ChangYong-Oh commented May 11, 2020 via email

@nataliebarcickikas
Copy link
Author

Hi Changyong,

One bottleneck in my simulations seems to be related to posterior sampling, specifically done in this line:

sample_posterior = posterior_sampling(surrogate_model, eval_inputs, eval_outputs, n_vertices, adj_mat_list,
The sampling takes a long time as shown in the timestamps below:
(11:11:52) Sampling
��������������������������������������������������������������������������������(11:16:58) 10% (1 of 10) |#####---------------------------------------------|��������������������������������������������������������������������������������(11:22:16) 20% (2 of 10) |##########----------------------------------------|��������������������������������������������������������������������������������(11:27:31) 30% (3 of 10) |###############-----------------------------------|��������������������������������������������������������������������������������(11:32:46) 40% (4 of 10) |####################------------------------------|��������������������������������������������������������������������������������(11:38:01) 50% (5 of 10) |#########################-------------------------|��������������������������������������������������������������������������������(11:43:22) 60% (6 of 10) |##############################--------------------|��������������������������������������������������������������������������������(11:48:32) 70% (7 of 10) |###################################---------------|��������������������������������������������������������������������������������(11:53:45) 80% (8 of 10) |########################################----------|��������������������������������������������������������������������������������(11:58:56) 90% (9 of 10) |#############################################-----|���������������������������������������������������������������������������������(12:04:08) 100% (10 of 10) |##################################################|
Can you explain what is happening in this series of steps and how one might be able to speed it up? When I open the corresponding function "posterior_sampling", I see there is a comment about what is good practice or not, but I am having troubles deciphering it.
Thanks a lot!
Best,
Natalie

@ChangYong-Oh
Copy link
Collaborator

ChangYong-Oh commented Jul 25, 2020 via email

@nataliebarcickikas
Copy link
Author

Hi ChangYong,

Thanks a lot for the clarification. Unfortunately, I am indeed using a couple of hundred categorical variables so this step is a real bottleneck...Can the elementwise slice sampling loop be parallelized using multiprocessing? I see that in each sampler, model.kernel fourier_freq_list and fourier_basis_list are updated, so I assume not.

Best,
Natalie

@nataliebarcickikas
Copy link
Author

Just following up on the above - not sure if parallelizing the elementwise slice sampling loop is mathematically sound in the algorithm?

Best,
Natalie

@ChangYong-Oh
Copy link
Collaborator

ChangYong-Oh commented Jul 29, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants