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

Which code is to reproduce the figure "Network Input Partioning" in readme? #3

Open
chenwydj opened this issue Jun 19, 2020 · 2 comments

Comments

@chenwydj
Copy link

Thank you very much!

@Kaleidophon
Copy link

I would also be interested in that!

@Kaleidophon
Copy link

So I am not sure if this is still a current issues for @chenwydj, but I'll post what I learned for the last couple of days here for future reference. How to reproduce this figures seems indeed not documented explicitly, but I think I got the solution after a lot of time reading through the code and even more trial and error.

You can start off by using the example in 2D_example.ipynb where we train a plnn_obj. Then, I used the following code to plot the polytopes induced by this network:

from _polytope_ import Polytope
from utilities import plot_polytopes_2d

geo = GeoCert(plnn_obj, hyperbox_bounds=(-3.5, 3), verbose=True, neuron_bounds="ia")
test_point = torch.Tensor([0, 0])
region_count = geo.run(test_point, lp_norm='l_inf', problem_type='count_regions',  decision_radius=3)

polylist = []

for polytope in region_count.seen_polytopes:
    config = plnn_obj.config_str_to_config_list(polytope)
    polytope_config = plnn_obj.compute_polytope_config(config)
    poly = Polytope.from_polytope_dict(polytope_config, test_point)
    polylist.append(poly)

plot_polytopes_2d(polylist, xylim=[-3.5, 3])

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

2 participants