Skip to main content

easy_module_attribute_getter

Installation:

pip install easy_module_attribute_getter

Simple example, using PytorchGetter which extends EasyModuleAttributeGetter:

1. Specify class names and arguments in your yaml config file:

models:
  modelA:
    densenet121:
      pretrained: True
      memory_efficient: True
  modelB:
    resnext50_32x4d:
      pretrained: True
losses:
  lossA:
    CrossEntropyLoss:
  lossB:
    L1Loss:

2. Read yaml file, and get objects from modules:

from easy_module_attribute_getter import YamlReader, PytorchGetter
yaml_reader = YamlReader()
args, _, _ = yaml_reader.load_yamls(['example.yaml'])
pytorch_getter = PytorchGetter()
models = pytorch_getter.get_multiple("model", args.models)
losses = pytorch_getter.get_multiple("loss", args.losses)
# "models" is a dictionary with keys "modelA" and "modelB" as specified
# in the yaml file. The values are the loaded objects (in this case
# pytorch models).
# The same is true for "losses".

Easily register your own modules into an existing getter.

from pytorch_metric_learning import losses, miners, samplers 
pytorch_getter = PytorchGetter()
# The 'loss' key already exists, so the 'losses' module will be appended to the existing module.
pytorch_getter.register('loss', losses) 
pytorch_getter.register('miner', miners)
pytorch_getter.register('sampler', samplers)

# Both modules will be searched when get() or get_multiple() is used.
# The first loss comes from the module that was just registered.
# The second loss comes from the Pytorch library that is registered by default.
metric_loss = pytorch_getter.get('loss', class_name='TripletMarginLoss', return_uninitialized=True)
kl_div_loss = pytorch_getter.get('loss', class_name='KLDivLoss', return_uninitialized=True)

Metadata

Release files for easy-module-attribute-getter 0.9.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-module-attribute-getter 0.9.11
File Size Uploaded Provenance Actions
easy_module_attribute_getter-0.9.11.tar.gz 4.8 kB Without provenance Details for easy_module_attribute_getter-0.9.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for easy-module-attribute-getter 0.9.11
File Interpreter ABI Platform Actions
easy_module_attribute_getter-0.9.11-py3-none-any.whl Python 3 none any Details for easy_module_attribute_getter-0.9.11-py3-none-any.whl

Total release size: 12.4 kB

Release files / easy_module_attribute_getter-0.9.11.tar.gz

Download URL easy_module_attribute_getter-0.9.11.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
96ad2d7f73e878900b29f87bf3f7f0826f48a5786eb05f8775b8d5b28d962329
BLAKE2b-256 checksum
How to use checksums
625451bbdbd129f487c5fb830fd5cb820f37c28da3e391640799d96bcc1f7f58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / easy_module_attribute_getter-0.9.11-py3-none-any.whl

Download URL easy_module_attribute_getter-0.9.11-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
765f9736cfda77f7475bd70839d5f81eb0fcc919a6221fe05a842bb224e0d62e
BLAKE2b-256 checksum
How to use checksums
03082f6a7003809be82c2bbedb69cb88b97664cf835bdec5cd19415043f39fd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Security for easy-module-attribute-getter 0.9.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.11 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page