-
Notifications
You must be signed in to change notification settings - Fork 77
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
How to train Topology Loss in batch images #19
Comments
How can I use |
Hi! I think the training in "code1" is not the best way to go anymore. However, you can look at "top_batch_cost" in utils to get inspiration to apply a specific diagram cost over a batch. Does this help? |
@bruel-gabrielsson Thank you for reply. TopologyLayer/topologylayer/functional/utils_dionysus.py Lines 8 to 24 in 1d62610
Besides the code, I want to use topology loss in segmentation task but there is a slow speed issue of topology loss. Do you have any idea enhancing it? |
Your codes 1 and 2 look so different. Could you let me know the difference of them? |
Hello, I am also interested in getting this to work for batches. @bruel-gabrielsson I will look at the mentioned script in utils and see how far I get. Thanks for your contribution with this loss functional :). |
I followed the example code here and altered the forward call in class Toploss in code2 to handle batches. I'll have to look at some visualizations to make sure the loss is functioning as expected, but pytorch is not complaining ;). |
Nice work! Probably could implement some parallelism if you need to speed things up! |
Thanks @bruel-gabrielsson :). Do you mean parallelism on the GPU side or CPU side? One aspect I'm unsure about is: does this loss function push a tensor to the CPU to calculate the PH gradient, then back to the GPU? Or does it all stay on the same device? Parallelism is def required since my implementation is slow, so thanks for that tip. I'll implement that for sure 👍 Edit: I missed the section in the README where it is stated: "You can use topologylayer with tensors that are on GPUs. However, because the persistent homology calculation takes place on CPU, there will be some overhead from memory movement." |
I'm looking into your example code1 and code2.
From the code2, I can understand how to train network with one image. But as code1 differs from code2 a lot, I can't understand how to train in batch.
What kinds of classes or functions do I have to use to train in batch?
The text was updated successfully, but these errors were encountered: