Git Product home page Git Product logo

Comments (7)

navid-mahmoudian avatar navid-mahmoudian commented on August 22, 2024 1

Ok. Thank you very much for your support. I guess we can close this issue.
Thank you again for this very nice framework.

from compressai.

jbegaint avatar jbegaint commented on August 22, 2024

Hi Navid, yes we had to get rid of this to add support for DataParallel (and we dropped nn.ParametersList also)

I just updated the changelog at https://github.com/InterDigitalInc/CompressAI/blob/master/NEWS.md with pointers. Here's the main change:

def configure_optimizers(net, args):
    """Separate parameters for the main optimizer and the auxiliary optimizer.
    Return two optimizers"""

    parameters = set(p for n, p in net.named_parameters() if not n.endswith(".quantiles"))
    aux_parameters = set(p for n, p in net.named_parameters() if n.endswith(".quantiles"))
    optimizer = optim.Adam((p for p in parameters if p.requires_grad), lr=1e-4)
    aux_optimizer = optim.Adam((p for p in aux_parameters if p.requires_grad), lr=1e-5)
    return optimizer, aux_optimizer

(You can also just define a single optimizer and per group options, see the pytorch doc here, but it's less flexible)

If you have some trained models you can update the state_dict to a compatible version with load_pretrained.

Please let me know if you have any issues.

from compressai.

navid-mahmoudian avatar navid-mahmoudian commented on August 22, 2024

Thank you Jean,

I think you have already corrected also examples/CompressAI Inference Demo.ipynb demo.

Thank you again.

from compressai.

navid-mahmoudian avatar navid-mahmoudian commented on August 22, 2024

Hello again Jean,
Before closing this issue, I found something strange that I wanted to share with you.

Since I have saved everything with the previous structure, I was able to double check something. I want to know if I am doing something wrong or you have the same results.

Let's imagine I am using ScaleHyperprior with quality of 5. For the number of parameters, with the previous structure I was getting:


# model parameters______________________: 5068035
# entropy bottleneck(s) parameters______: 7808

But with the new structure I get:


# model parameters______________________: 5075459
# entropy bottleneck(s) parameters______: 384

The sum of the two versions are equal (5068035+7808 == 5075459+384), but as you can see the number of parameters for entropy bottleneck and model parameters are very different. I am using the following code in the new structure to find the number of parameters:


parameters = set(p for n, p in net.named_parameters() if not n.endswith(".quantiles"))
aux_parameters = set(p for n, p in net.named_parameters() if n.endswith(".quantiles"))
optimizer = torch.optim.Adam((p for p in parameters if p.requires_grad), lr=args.learning_rate)
optimizer_aux = torch.optim.Adam((p for p in aux_parameters if p.requires_grad), lr=args.learning_rate_aux)

n_parameters_dict = dict()
n_parameters_dict["# model parameters"] = sum(p.numel() for p in parameters if p.requires_grad)
n_parameters_dict["# entropy bottleneck(s) parameters"] = sum(p.numel() for p in aux_parameters if p.requires_grad)
print(n_parameters_dict)


Have you seen the same issue? I am asking because it might be a bug in my code because I am not exactly using your code.

best,
Navid

from compressai.

jbegaint avatar jbegaint commented on August 22, 2024

Hi Navid, that's correct.

Previously the aux_parameters group was containing all the parameters of the entropy bottlenecks, which is not 100% correct since only the quantiles should be updated by the auxiliary optimizer. However it was not impacting the convergence or the performance (the only difference was the learning rate for the entropy bottlenecks parameters).
See this other issue also: #16.

The current implementation in the example should be cleaner and asserts that there's no overlap (or omission) between parameters groups.

from compressai.

navid-mahmoudian avatar navid-mahmoudian commented on August 22, 2024

Thank you Jean. That's very interesting.

Just the last question. Don't you think this has an effect on backward compatibility? For those parameters that are moved from aux to model parameters, all models learned with the previous version were using another learning rate for aux parameters which is less than the learning rate for the model parameters. I think this has an impact. Have you tested to see the difference in the performance?

from compressai.

jbegaint avatar jbegaint commented on August 22, 2024

Hi Navid, I've trained multiple models with both versions and haven't noticed any performance difference. But please let me know if you observe any issue.

from compressai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.