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
Error Instantiating pl.LightningDataModule with hydra.utils.instantiate in run.py
Description:
Issue Overview:
No changes were made to the code. When attempting to instantiate a pl.LightningDataModule in run.py using hydra.utils. instantiate, the process fails with an InstantiationException related to the torchmeta.datasets.omniglot.Omniglot class. It appears that the num_classes_per_task parameter is unexpectedly None.
Errror:
The instantiation process throws an InstantiationException, indicating a problem with the num_classes_per_task parameter being None:
发生异常: InstantiationException (note: full exception trace is shown but execution is paused at: _run_module_as_main)
Error in call to target 'torchmeta.datasets.omniglot.Omniglot':
TypeError("Unknown type for `num_classes_per_task`. Expected `int`, got `<class 'NoneType'>`.")
full_key: data.datamodule.datasets.train
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 92, in _call_target
return _target_(*args, **kwargs)
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/torchmeta-1.8.0-py3.8.egg/torchmeta/datasets/omniglot.py", line 103, in __init__
super(Omniglot, self).__init__(dataset, num_classes_per_task,
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/torchmeta-1.8.0-py3.8.egg/torchmeta/utils/data/dataset.py", line 245, in __init__
raise TypeError('Unknown type for `num_classes_per_task`. Expected '
TypeError: Unknown type for `num_classes_per_task`. Expected `int`, got `<class 'NoneType'>`.
The above exception was the direct cause of the following exception:
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 97, in _call_target
raise InstantiationException(msg) from e
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 347, in instantiate_node
return _call_target(_target_, partial, args, kwargs, full_key)
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 366, in instantiate_node
cfg[key] = instantiate_node(
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 342, in instantiate_node
value = instantiate_node(
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/instantiate/_instantiate2.py", line 226, in instantiate
return instantiate_node(
File "/home/Code/Few-Shot/lightning-maml-main/src/run.py", line 96, in run
datamodule: pl.LightningDataModule = hydra.utils.instantiate(
File "/home/Code/Few-Shot/lightning-maml-main/src/run.py", line 158, in main
run(cfg)
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/core/utils.py", line 186, in run_job
ret.return_value = task_function(task_cfg)
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/core/utils.py", line 260, in return_value
raise self._return_value
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 132, in run
_ = ret.return_value
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/utils.py", line 458, in <lambda>
lambda: hydra.run(
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
raise ex
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
raise ex
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/utils.py", line 457, in _run_app
run_and_report(
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra
_run_app(
File "/root/anaconda3/envs/metawifi/lib/python3.8/site-packages/hydra/main.py", line 94, in decorated_main
_run_hydra(
File "/home/Code/Few-Shot/lightning-maml-main/src/run.py", line 162, in <module>
main()
File "/root/anaconda3/envs/metawifi/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/root/anaconda3/envs/metawifi/lib/python3.8/runpy.py", line 194, in _run_module_as_main (Current frame)
return _run_code(code, main_globals, None,
hydra.errors.InstantiationException: Error in call to target 'torchmeta.datasets.omniglot.Omniglot':
TypeError("Unknown type for `num_classes_per_task`. Expected `int`, got `<class 'NoneType'>`.")
full_key: data.datamodule.datasets.train
config:
No changes were made to the configuration
# @package _group_
# The module is communicating with pytorch-lightning
datamodule:
_target_: pl.datamodule.MetaDataModule
datasets:
train:
_target_: torchmeta.datasets.Omniglot
root: /home/Code/Few-Shot/lightning-maml-main/data
meta_train: True
download: True
val:
_target_: torchmeta.datasets.Omniglot
root: /home/Code/Few-Shot/lightning-maml-main/data
meta_val: True
download: True
test:
_target_: torchmeta.datasets.Omniglot
root: /home/Code/Few-Shot/lightning-maml-main/data
meta_test: True
download: True
# number of classes for each task
nway: 5
# number of inner steps for adaptation
num_inner_steps: 1
# input transformations
transforms:
- _target_: torchvision.transforms.Resize
size: 28
- _target_: torchvision.transforms.ToTensor
target_transform:
_target_: torchmeta.transforms.Categorical
# this augmentation creates new classes based on rotation.
class_augmentations:
- _target_: common.transform.Rotation
angle:
- 90
- 180
- 270
# number of tasks for each metadataset split
batch_size:
train: 20
val: 20
test: 20
# number of samples per class for a task
kshot:
support: 5
query: 5
# number of workers to load data to reduce bottleneck
num_workers:
train: 2
val: 2
test: 2
Attempts to Resolve:
Checked and verified the configuration files for any obvious misconfigurations.
Searched for similar issues in the repository's issue tracker and on Stack Overflow.
I would appreciate any guidance on resolving this issue to proceed with using the project. Thank you in advance for your help.
The text was updated successfully, but these errors were encountered:
Title:
Error Instantiating pl.LightningDataModule with hydra.utils.instantiate in run.py
Description:
Issue Overview:
No changes were made to the code. When attempting to instantiate a pl.LightningDataModule in run.py using hydra.utils. instantiate, the process fails with an InstantiationException related to the torchmeta.datasets.omniglot.Omniglot class. It appears that the num_classes_per_task parameter is unexpectedly None.
Errror:
The instantiation process throws an InstantiationException, indicating a problem with the num_classes_per_task parameter being None:
config:
No changes were made to the configuration
Environment:
python:3.8.19
pytorch-lightning:2.2.1
torchmet: 1.8.0
hydra-core:1.3.2
Attempts to Resolve:
Checked and verified the configuration files for any obvious misconfigurations.
Searched for similar issues in the repository's issue tracker and on Stack Overflow.
I would appreciate any guidance on resolving this issue to proceed with using the project. Thank you in advance for your help.
The text was updated successfully, but these errors were encountered: