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

Fix gradient inversion #196

Merged
merged 10 commits into from
Oct 13, 2023
Merged

Fix gradient inversion #196

merged 10 commits into from
Oct 13, 2023

Conversation

mogres
Copy link
Collaborator

@mogres mogres commented Sep 26, 2023

Problem

Gradient inversion used distances instead of weights. This could result in unexpected inversion.

Solution

The type of inversion can be specified as an option now. invert: "distance" inverts the scaled distances and invert: "weight" inverts the weights after calculation.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Change summary:

  • add option to specify inversion using weights or distances
  • add default values
  • update test recipes to visualize inversion
  • add credentials file to gitignore

Steps to Verify:

  1. pack -r cellpack/tests/recipes/v2/test_mesh_image_gradient.json -c cellpack/tests/packing-configs/test_mesh_config.json
  2. Change invert: "weight" to invert: "distance" to visualize alternative inversion.

Screenshots:

Inverting distances:
image

Inverting weights:
image

Keyfiles:

  1. Gradient.py

@github-actions
Copy link

github-actions bot commented Sep 26, 2023

Packing analysis report

Analysis for packing results located at cellpack/tests/outputs/test_spheres/spheresSST

Ingredient name Encapsulating radius Average number packed
ext_A 25 236.0

Packing image

Packing image

Distance analysis

Expected minimum distance: 50.00
Actual minimum distance: 50.01

Ingredient key Pairwise distance distribution
ext_A Distance distribution ext_A

@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (9105668) 98.52% compared to head (a918184) 98.52%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #196   +/-   ##
=======================================
  Coverage   98.52%   98.52%           
=======================================
  Files          16       16           
  Lines         476      476           
=======================================
  Hits          469      469           
  Misses          7        7           
Files Coverage Δ
cellpack/tests/test_gradient_data.py 100.00% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rugeli
Copy link
Collaborator

rugeli commented Sep 27, 2023

Looks good to me! I was able to pack the test recipe, however, it's taking a very long time to load the model in Simularium, I'm still waiting to visualize the result.

One question(might not related to this PR):
In terminal logs, the message Packing test_mesh_image_gradient_1.0.0: appeared twice with the first one remaining at 0% progress. Should we make any modifications to address this if one of them is being skipped or something?
Screenshot 2023-09-27 at 2 27 56 PM

@mogres
Copy link
Collaborator Author

mogres commented Sep 27, 2023

@rugeli, were you able to visualize the output? It might help if you change the radius of the primitive_sphere to 1 so that there are fewer grid points to visualize.

As for the progress bar, it gets reprinted/interrupted when something else gets printed to the terminal. The Known pipe types message seems to have reset the bar -- we can look into what causes that message and whether we can prevent it from being displayed.

@rugeli
Copy link
Collaborator

rugeli commented Sep 28, 2023

@rugeli, were you able to visualize the output? It might help if you change the radius of the primitive_sphere to 1 so that there are fewer grid points to visualize.

As for the progress bar, it gets reprinted/interrupted when something else gets printed to the terminal. The Known pipe types message seems to have reset the bar -- we can look into what causes that message and whether we can prevent it from being displayed.

Thanks for getting back to me! I wasn't able to visualize the output yesterday. I just changed the primitive_sphere to 1, but the simularium has been in loading for the past 20 minutes.

@mogres mogres marked this pull request as draft October 6, 2023 20:59
@mogres mogres marked this pull request as ready for review October 9, 2023 18:32
@mogres
Copy link
Collaborator Author

mogres commented Oct 12, 2023

@rugeli the recipe has been updated so you should be able to run it faster and visualize in simularium. Let me know if there are still any issues

@mogres mogres merged commit 5da57e0 into main Oct 13, 2023
7 checks passed
@mogres mogres deleted the fix/gradient_invert branch October 13, 2023 21:36
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

Successfully merging this pull request may close these issues.

4 participants