antonfrancois / Demeter_metamorphosis

Open library for LDDMM and Metamorphosis in PyTorch
20 stars 3 forks source link

issue about computational efficiency and memory consumption #4

Open 18370029656 opened 2 hours ago

18370029656 commented 2 hours ago

Hello, sorry to bother you. Can you tell me the number of parameters and the computational efficiency of the model? I can't seem to get the number of parameters for the model and am looking forward to your reply.

antonfrancois commented 2 hours ago

Hello !

Thank you for your interest ! The library is not well documented yet (working on it) so feel free to ask questions! Depends on what are you referring to as a "parameter". If you refer to the parameter as the one we optimize upon in machine learning: First I want to note, that what I am proposing here is not a model learned. So mathematically speaking, to optimize the metamorphosis we optimize upon the initial 'momentum' $p_0$. In the case of images (function of $I:\Omega \mapsto \mathbb R$ where $\Omega$ is the number of pixels) we set the evolution of image $\dot I = v \cdot I + \mu z$ ($v$ the field, $z$ the residual). In the case of images, the momentum is equal to the residuals. And the momentum is of the same dimension as the image.

If you are referring to parameters as the constants to tweak, it depends which model you want to use. For LDDMM, you have to set the parameters relative to the optimization: integration_step,n_iter,grad_coef and sigma which is the smoothing parameter of the Gaussian RKHS. For Metamorphosis, you have to add mu to control the amount of intensity changes and rho which control the force of the vector field. In practice, you can set one or the other to 1 and tweak the other accordingly.

If you intend to start using the library, I will speed up the documentation process for you to understand more what you are working with.

For the computational efficiency, it is hard to say. Why do you need this information?

I hope it answers your questions

18370029656 commented 2 hours ago

Sorry, I may not have expressed myself clearly. I would like to get the memory consumption and computational efficiency of the model to compare it with other models.

---Original--- From: "Anton @.> Date: Fri, Nov 15, 2024 22:47 PM To: @.>; Cc: @.**@.>; Subject: Re: [antonfrancois/Demeter_metamorphosis] issue about computationalefficiency and memory consumption (Issue #4)

Hello !

Thank you for your interest ! The library is not well documented yet (working on it) so feel free to ask questions! Depends on what are you referring to as a "parameter". If you refer to the parameter as the one we optimize upon in machine learning: First I want to note, that what I am proposing here is not a model learned. So mathematically speaking, to optimize the metamorphosis we optimize upon the initial 'momentum' $p_0$. In the case of images (function of $I:\Omega \mapsto \mathbb R$ where $\Omega$ is the number of pixels) we set the evolution of image $\dot I = v \cdot I + \mu z$ ($v$ the field, $z$ the residual). In the case of images, the momentum is equal to the residuals. And the momentum is of the same dimension as the image.

If you are referring to parameters as the constants to tweak, it depends which model you want to use. For LDDMM, you have to set the parameters relative to the optimization: integration_step,n_iter,grad_coef and sigma which is the smoothing parameter of the Gaussian RKHS. For Metamorphosis, you have to add mu to control the amount of intensity changes and rho which control the force of the vector field. In practice, you can set one or the other to 1 and tweak the other accordingly.

If you intend to start using the library, I will speed up the documentation process for you to understand more what you are working with.

For the computational efficiency, it is hard to say. Why do you need this information?

I hope it answers your questions

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

antonfrancois commented 1 hour ago

For now, I cannot answer your questions about the theoretical values.

Empirically, the results will depend very much on the images you will use. Most of the memory is used by the backward pass implemented by torch and I depend on that. If you want to compare different models I suggest you to design an experiment measuring the efficiency using the same computer and methods. I can help you to tweak the parameters and use the library.

18370029656 commented 1 hour ago

Thank you very much for your quick reply! When I print the memory consumption of a model using the following code, what should the ”model“ here point to for your model, weighted_metamorphosis or Weighted_optim?

------------------ 原始邮件 ------------------ 发件人: "antonfrancois/Demeter_metamorphosis" @.>; 发送时间: 2024年11月15日(星期五) 晚上11:54 @.>; @.**@.>; 主题: Re: [antonfrancois/Demeter_metamorphosis] issue about computational efficiency and memory consumption (Issue #4)

For now, I cannot answer your questions about the theoretical values.

Empirically, the results will depend very much on the images you will use. Most of the memory is used by the backward pass implemented by torch and I depend on that. If you want to compare different models I suggest you to design an experiment measuring the efficiency using the same computer and methods. I can help you to tweak the parameters and use the library.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>