gt4sd.algorithms.generation.polymer_blocks.core module

PaccMann vanilla generator trained on polymer building blocks (catalysts/monomers).

Summary

Classes:

PolymerBlocks

PolymerBlocksGenerator

Configuration to generate subunits of polymers.

Reference

class PolymerBlocks(configuration, target=None)[source]

Bases: GeneratorAlgorithm[S, None]

__init__(configuration, target=None)[source]

Polymer blocks generation.

Parameters
  • configuration (AlgorithmConfiguration) – domain and application specification, defining types and validations.

  • target (None) – unused since it is not a conditional generator.

Example

An example for generating small molecules (SMILES) that resembles monomers/catalysts for polymer synthesis:

configuration = PolymerBlocksGenerator()
polymer_blocks = PolymerBlocks(configuration=configuration)
items = list(polymer_blocks.sample(10))
print(items)
get_generator(configuration, target)[source]

Get the function to sample batches via the Generator.

Parameters
  • configuration (AlgorithmConfiguration[~S, None]) – helps to set up the application.

  • target (None) – context or condition for the generation. Unused in the algorithm.

Return type

Callable[[], Iterable[Any]]

Returns

callable generating a batch of items.

validate_configuration(configuration)[source]

Overload to validate the a configuration for the algorithm.

Parameters

configuration (AlgorithmConfiguration) – the algorithm configuration.

Raises

InvalidAlgorithmConfiguration – in case the configuration for the algorithm is invalid.

Return type

AlgorithmConfiguration

Returns

the validated configuration.

__abstractmethods__ = frozenset({})
__annotations__ = {'generate': 'Untargeted', 'generator': 'Union[Untargeted, Targeted[T]]', 'max_runtime': 'int', 'max_samples': 'int', 'target': 'Optional[T]'}
__doc__ = None
__module__ = 'gt4sd.algorithms.generation.polymer_blocks.core'
__orig_bases__ = (gt4sd.algorithms.core.GeneratorAlgorithm[~S, NoneType],)
__parameters__ = (~S,)
_abc_impl = <_abc._abc_data object>
class PolymerBlocksGenerator(*args, **kwargs)[source]

Bases: PolymerBlocksGenerator, Generic[T]

Configuration to generate subunits of polymers.

algorithm_type: ClassVar[str] = 'generation'

General type of generative algorithm.

domain: ClassVar[str] = 'materials'

General application domain. Hints at input/output types.

algorithm_version: str = 'v0'

To differentiate between different versions of an application.

There is no imposed naming convention.

batch_size: int = 32
generated_length: int = 100
get_target_description()[source]

Get description of the target for generation.

Return type

Optional[Dict[str, str], None]

Returns

target description, returns None in case no target is used.

get_conditional_generator(resources_path)[source]
Return type

Generator

validate_item(item)[source]

Overload to validate an item.

Parameters

item (str) – validate an item.

Raises

InvalidItem – in case the item can not be validated.

Returns

the validated item.

Return type

S

classmethod get_filepath_mappings_for_training_pipeline_arguments()[source]

Ger filepath mappings for the given training pipeline arguments.

Parameters

training_pipeline_arguments (TrainingPipelineArguments) – training pipeline arguments.

Return type

Dict[str, str]

Returns

a mapping between artifacts’ files and training pipeline’s output files.

__annotations__ = {'algorithm_application': 'ClassVar[str]', 'algorithm_name': 'ClassVar[str]', 'algorithm_type': typing.ClassVar[str], 'algorithm_version': <class 'str'>, 'batch_size': <class 'int'>, 'domain': typing.ClassVar[str], 'generated_length': <class 'int'>}
__dataclass_fields__ = {'algorithm_application': Field(name='algorithm_application',type=typing.ClassVar[str],default='PolymerBlocksGenerator',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_name': Field(name='algorithm_name',type=typing.ClassVar[str],default='PolymerBlocks',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_type': Field(name='algorithm_type',type=typing.ClassVar[str],default='generation',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_version': Field(name='algorithm_version',type=<class 'str'>,default='v0',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'batch_size': Field(name='batch_size',type=<class 'int'>,default=32,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Batch size used for the generative model sampling.'}),kw_only=False,_field_type=_FIELD), 'domain': Field(name='domain',type=typing.ClassVar[str],default='materials',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'generated_length': Field(name='generated_length',type=<class 'int'>,default=100,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Maximum length in tokens of the generated molcules (relates to the SMILES length).'}),kw_only=False,_field_type=_FIELD)}
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)
__doc__ = 'Configuration to generate subunits of polymers.'
__eq__(other)

Return self==value.

__hash__ = None
__init__(*args, **kwargs)
__match_args__ = ('algorithm_version', 'batch_size', 'generated_length')
__module__ = 'gt4sd.algorithms.generation.polymer_blocks.core'
__orig_bases__ = (<class 'types.PolymerBlocksGenerator'>, typing.Generic[~T])
__parameters__ = (~T,)
__pydantic_complete__ = True
__pydantic_config__ = {}
__pydantic_core_schema__ = {'cls': <class 'gt4sd.algorithms.generation.polymer_blocks.core.PolymerBlocksGenerator'>, 'config': {'title': 'PolymerBlocksGenerator'}, 'fields': ['algorithm_version', 'batch_size', 'generated_length'], 'frozen': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'gt4sd.algorithms.generation.polymer_blocks.core.PolymerBlocksGenerator'>, title=None)]}, 'post_init': False, 'ref': 'types.PolymerBlocksGenerator:94662829263536', 'schema': {'collect_init_only': False, 'computed_fields': [], 'dataclass_name': 'PolymerBlocksGenerator', 'fields': [{'type': 'dataclass-field', 'name': 'algorithm_version', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'v0'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'batch_size', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 32}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'generated_length', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 100}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}], 'type': 'dataclass-args'}, 'slots': True, 'type': 'dataclass'}
__pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})
__pydantic_fields__ = {'algorithm_version': FieldInfo(annotation=str, required=False, default='v0', init=True, init_var=False, kw_only=False), 'batch_size': FieldInfo(annotation=int, required=False, default=32, description='Batch size used for the generative model sampling.', init=True, init_var=False, kw_only=False), 'generated_length': FieldInfo(annotation=int, required=False, default=100, description='Maximum length in tokens of the generated molcules (relates to the SMILES length).', init=True, init_var=False, kw_only=False)}
__pydantic_serializer__ = SchemaSerializer(serializer=Dataclass(     DataclassSerializer {         class: Py(             0x00005618684fcab0,         ),         serializer: Fields(             GeneralFieldsSerializer {                 fields: {                     "generated_length": SerField {                         key_py: Py(                             0x00007f1dc4fed200,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             WithDefault(                                 WithDefaultSerializer {                                     default: Default(                                         Py(                                             0x00007f1ea9468d50,                                         ),                                     ),                                     serializer: Int(                                         IntSerializer,                                     ),                                 },                             ),                         ),                         required: true,                     },                     "algorithm_version": SerField {                         key_py: Py(                             0x00007f1dc4fef140,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             WithDefault(                                 WithDefaultSerializer {                                     default: Default(                                         Py(                                             0x00007f1ea52cf3f0,                                         ),                                     ),                                     serializer: Str(                                         StrSerializer,                                     ),                                 },                             ),                         ),                         required: true,                     },                     "batch_size": SerField {                         key_py: Py(                             0x00007f1dc39020f0,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             WithDefault(                                 WithDefaultSerializer {                                     default: Default(                                         Py(                                             0x00007f1ea94684d0,                                         ),                                     ),                                     serializer: Int(                                         IntSerializer,                                     ),                                 },                             ),                         ),                         required: true,                     },                 },                 computed_fields: Some(                     ComputedFields(                         [],                     ),                 ),                 mode: SimpleDict,                 extra_serializer: None,                 filter: SchemaFilter {                     include: None,                     exclude: None,                 },                 required_fields: 3,             },         ),         fields: [             Py(                 0x00007f1ea52ed250,             ),             Py(                 0x00007f1ea52ccc70,             ),             Py(                 0x00007f1dca9b95c0,             ),         ],         name: "PolymerBlocksGenerator",     }, ), definitions=[])
__pydantic_validator__ = SchemaValidator(title="PolymerBlocksGenerator", validator=Dataclass(     DataclassValidator {         strict: false,         validator: DataclassArgs(             DataclassArgsValidator {                 fields: [                     Field {                         kw_only: false,                         name: "algorithm_version",                         py_name: Py(                             0x00007f1ea52ed250,                         ),                         init: true,                         init_only: false,                         lookup_key: Simple {                             key: "algorithm_version",                             py_key: Py(                                 0x00007f1dc4fed160,                             ),                             path: LookupPath(                                 [                                     S(                                         "algorithm_version",                                         Py(                                             0x00007f1dc4fed110,                                         ),                                     ),                                 ],                             ),                         },                         validator: WithDefault(                             WithDefaultValidator {                                 default: Default(                                     Py(                                         0x00007f1ea52cf3f0,                                     ),                                 ),                                 on_error: Raise,                                 validator: Str(                                     StrValidator {                                         strict: false,                                         coerce_numbers_to_str: false,                                     },                                 ),                                 validate_default: false,                                 copy_default: false,                                 name: "default[str]",                                 undefined: Py(                                     0x00007f1ea71db950,                                 ),                             },                         ),                         frozen: false,                     },                     Field {                         kw_only: false,                         name: "batch_size",                         py_name: Py(                             0x00007f1ea52ccc70,                         ),                         init: true,                         init_only: false,                         lookup_key: Simple {                             key: "batch_size",                             py_key: Py(                                 0x00007f1dc38c9d70,                             ),                             path: LookupPath(                                 [                                     S(                                         "batch_size",                                         Py(                                             0x00007f1dc3902470,                                         ),                                     ),                                 ],                             ),                         },                         validator: WithDefault(                             WithDefaultValidator {                                 default: Default(                                     Py(                                         0x00007f1ea94684d0,                                     ),                                 ),                                 on_error: Raise,                                 validator: Int(                                     IntValidator {                                         strict: false,                                     },                                 ),                                 validate_default: false,                                 copy_default: false,                                 name: "default[int]",                                 undefined: Py(                                     0x00007f1ea71db950,                                 ),                             },                         ),                         frozen: false,                     },                     Field {                         kw_only: false,                         name: "generated_length",                         py_name: Py(                             0x00007f1dca9b95c0,                         ),                         init: true,                         init_only: false,                         lookup_key: Simple {                             key: "generated_length",                             py_key: Py(                                 0x00007f1dc4fef280,                             ),                             path: LookupPath(                                 [                                     S(                                         "generated_length",                                         Py(                                             0x00007f1dc4fef190,                                         ),                                     ),                                 ],                             ),                         },                         validator: WithDefault(                             WithDefaultValidator {                                 default: Default(                                     Py(                                         0x00007f1ea9468d50,                                     ),                                 ),                                 on_error: Raise,                                 validator: Int(                                     IntValidator {                                         strict: false,                                     },                                 ),                                 validate_default: false,                                 copy_default: false,                                 name: "default[int]",                                 undefined: Py(                                     0x00007f1ea71db950,                                 ),                             },                         ),                         frozen: false,                     },                 ],                 positional_count: 3,                 init_only_count: None,                 dataclass_name: "PolymerBlocksGenerator",                 validator_name: "dataclass-args[PolymerBlocksGenerator]",                 extra_behavior: Ignore,                 extras_validator: None,                 loc_by_alias: true,             },         ),         class: Py(             0x00005618684fcab0,         ),         fields: [             Py(                 0x00007f1ea52ed250,             ),             Py(                 0x00007f1ea52ccc70,             ),             Py(                 0x00007f1dca9b95c0,             ),         ],         post_init: None,         revalidate: Never,         name: "PolymerBlocksGenerator",         frozen: false,         slots: true,     }, ), definitions=[], cache_strings=True)
__repr__()

Return repr(self).

__signature__ = <Signature (algorithm_version: str = 'v0', batch_size: int = 32, generated_length: int = 100) -> None>
__wrapped__

alias of PolymerBlocksGenerator