librascal icon indicating copy to clipboard operation
librascal copied to clipboard

Pad Representation with zeros for non-present species

Open rosecers opened this issue 3 years ago • 5 comments

I have this problem quite often, where I'm computing a subset of SOAP vectors for who species ABCD are present, then another subset where only ABD are present. I know that I can use the species pair dictionary to collect SOAPs per species pair, but it would be far, far more convenient to do something like this:

hyperparameters = {
    "soap_type": "PowerSpectrum",
    ...

    # I know this keyword exists, but seems to only affect `expansion_by_species_method`
    "global_species": [A, B, C, D, ...] 
}
soap = SOAP(**hyperparameters)

featuresABCD = soap.transform(framesABCD).get_features(soap)
featuresABD = soap.transform(framesABD).get_features(soap)

where featuresABCD and featuresABD have the same indexing and shape.

rosecers avatar May 06 '21 15:05 rosecers

For global_species to work, I think you also have to set expansion_by_species_method="user defined" in the hypers. Is that what you meant by the comment in your example?

max-veit avatar May 06 '21 16:05 max-veit

Would it make sense to have a non-null "global_species" automatically set "user_defined" expansion_by_species_method?

On Thu, 6 May 2021 at 18:15, Max Veit @.***> wrote:

For global_species to work, I think you also have to set expansion_by_species_method="user defined" in the hypers. Is that what you meant by the comment in your example?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cosmo-epfl/librascal/issues/350#issuecomment-833651912, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIREZ3W6CS7LUNSYXAIQ7DTMK6A5ANCNFSM44HK2Y7Q .

ceriottm avatar May 06 '21 19:05 ceriottm

Yes, that would fix it quite nicely!

On May 6, 2021, at 9:41 PM, Michele Ceriotti @.***> wrote:

Would it make sense to have a non-null "global_species" automatically set "user_defined" expansion_by_species_method?

On Thu, 6 May 2021 at 18:15, Max Veit @.***> wrote:

For global_species to work, I think you also have to set expansion_by_species_method="user defined" in the hypers. Is that what you meant by the comment in your example?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cosmo-epfl/librascal/issues/350#issuecomment-833651912, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIREZ3W6CS7LUNSYXAIQ7DTMK6A5ANCNFSM44HK2Y7Q .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cosmo-epfl/librascal/issues/350#issuecomment-833809413, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALKVP3RGO7NW2MLR4JQUGETTMLWILANCNFSM44HK2Y7Q.

rosecers avatar May 07 '21 07:05 rosecers

Ok, this is now implemented in bugfix/soap_global_species. Let me know if you want to add tests as well; I think that could be a good idea.

max-veit avatar May 07 '21 17:05 max-veit

Looking at the code, I have a few thoughts (first of which is turning the branch into a draft PR).

  • Is there a need to have the two separate input parameters (global_species and expansion_by_species_method) if inputting one overrides the other? Why not have an option to expansion_by_species_method that anticipates a list of global species?
  • If kept two parameters, I would suggest a warning in lines 219-220

rosecers avatar May 10 '21 09:05 rosecers