You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we publish configs with our official models so that it is easy for other people to use them. We do this by removing the properties that are hardware dependent (e.g., device: cuda or batch_size: 4) and resaving the files. This happens in a function that does the work for the configs that are passed:
"""Return only params that are not data or machine specific.
Used for generating official configs.
"""
ifsubset=="train_config":
config=full_configuration[subset]
forkeyin [
"data_dir",
"dry_run",
"batch_size",
"auto_lr_find",
"gpus",
"num_workers",
"max_epochs",
"weight_download_region",
"split_proportions",
"save_dir",
"overwrite",
"skip_load_validation",
"from_scratch",
"model_cache_dir",
"predict_all_zamba_species",
]:
config.pop(key)
elifsubset=="video_loader_config":
config=full_configuration[subset]
if"megadetector_lite_config"inconfig.keys():
config["megadetector_lite_config"].pop("device")
forkeyin ["cache_dir", "cleanup_cache"]:
config.pop(key)
returnconfig
We can simplify and generalize this code by adding a hardware_dependent_fields property to the config and then a hardware_independent_dict method to the model that will serialize the config, removing all the hardware_dependent_fields on that model and any children that inherit from the same base model. Here's a working implementation with a small example config:
The text was updated successfully, but these errors were encountered:
pjbull
changed the title
Not worth holding merging for, but if this logic lives on the config instance like before, we don't have to if/else subsets in this function.
Add hardware_dependent_fields to ZambaBaseModel's Config
Oct 26, 2021
Currently, we publish configs with our official models so that it is easy for other people to use them. We do this by removing the properties that are hardware dependent (e.g.,
device: cuda
orbatch_size: 4
) and resaving the files. This happens in a function that does the work for the configs that are passed:zamba/zamba/models/publish_models.py
Lines 15 to 49 in 33c1c2a
We can simplify and generalize this code by adding a
hardware_dependent_fields
property to the config and then ahardware_independent_dict
method to the model that will serialize the config, removing all thehardware_dependent_fields
on that model and any children that inherit from the same base model. Here's a working implementation with a small example config:The text was updated successfully, but these errors were encountered: