gt4sd.algorithms.generation.polymer_blocks.implementation module¶
Implementation details for PaccMann vanilla generator trained on polymer building blocks (catalysts/monomers).
Summary¶
Classes:
Reference¶
- class Generator(resources_path, generated_length=100, batch_size=32, device=None)[source]¶
Bases:
object
- __init__(resources_path, generated_length=100, batch_size=32, device=None)[source]¶
Initialize the encoder/decoder generative model.
- Parameters
resources_path (
str
) – directory where to find models and parameters.generated_length (
int
) – length of the generated molecule in tokens. Defaults to 100.batch_size (
int
) – size of the batch. Defaults to 1.device (
Union
[device
,str
,None
]) – device where the inference is running either as a dedicated class or a string. If not provided is inferred.
- load_pretrained_paccmann(params_file, lang_file, weights_file, batch_size)[source]¶
Load a pretrained PaccMann model.
- Parameters
params_file (
str
) – file for the parameters.lang_file (
str
) – language file.weights_file (
str
) – serialized weights file.batch_size (
int
) – size of the batch.
- Return type
None
- decode(latent_z, search=SamplingSearch())[source]¶
Decodes a sequence of tokens given a position in the latent space.
- Parameters
latent_z (
Tensor
) – a batch size x latent size tensor.search (
SamplingSearch
) – defaults to sampling multinomial search.
- Return type
List
[int
]- Returns
list of list of token indices.
- __dict__ = mappingproxy({'__module__': 'gt4sd.algorithms.generation.polymer_blocks.implementation', '__init__': <function Generator.__init__>, 'load_pretrained_paccmann': <function Generator.load_pretrained_paccmann>, 'decode': <function Generator.decode>, 'sample': <function Generator.sample>, '__dict__': <attribute '__dict__' of 'Generator' objects>, '__weakref__': <attribute '__weakref__' of 'Generator' objects>, '__doc__': None, '__annotations__': {}})¶
- __doc__ = None¶
- __module__ = 'gt4sd.algorithms.generation.polymer_blocks.implementation'¶
- __weakref__¶
list of weak references to the object (if defined)