uni2ts icon indicating copy to clipboard operation
uni2ts copied to clipboard

TypeError: MoiraiModule.__init__() missing 7 required positional arguments: 'distr_output', 'd_model', 'num_layers', 'patch_sizes', 'max_seq_len', 'attn_dropout_p', and 'dropout_p'

Open Sample-design-alt opened this issue 1 year ago • 3 comments

when I perform the code in the https://github.com/SalesforceAIResearch/uni2ts/blob/main/example/moirai_forecast.ipynb, there are some error occur. How should I solve this problem?

TypeError Traceback (most recent call last) Cell In[5], line 3 1 # Prepare model 2 model = MoiraiForecast( ----> 3 module=MoiraiModule.from_pretrained( 4 f"Salesforce/moirai-1.0-R-{SIZE}", 5 ), 6 prediction_length=metadata.prediction_length, 7 context_length=CTX, 8 patch_size=PSZ, 9 num_samples=100, 10 target_dim=metadata.target_dim, 11 feat_dynamic_real_dim=metadata.feat_dynamic_real_dim, 12 past_feat_dynamic_real_dim=metadata.past_feat_dynamic_real_dim, 13 ) 15 predictor = model.create_predictor(batch_size=BSZ) 16 forecasts = predictor.predict(test_data.input)

File ~/nudt/uni2ts/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114, in validate_hf_hub_args.._inner_fn(*args, **kwargs) 111 if check_use_auth_token: 112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.name, has_token=has_token, kwargs=kwargs) --> 114 return fn(*args, **kwargs)

File ~/nudt/uni2ts/venv/lib/python3.10/site-packages/huggingface_hub/hub_mixin.py:511, in ModelHubMixin.from_pretrained(cls, pretrained_model_name_or_path, force_download, resume_download, proxies, token, cache_dir, local_files_only, revision, **model_kwargs) 508 if cls._hub_mixin_inject_config: 509 model_kwargs["config"] = config --> 511 instance = cls._from_pretrained( 512 model_id=str(model_id), 513 revision=revision, 514 cache_dir=cache_dir, 515 force_download=force_download, 516 proxies=proxies, 517 resume_download=resume_download, 518 local_files_only=local_files_only, 519 token=token, 520 **model_kwargs, 521 ) 523 # Implicitly set the config as instance attribute if not already set by the class 524 # This way config will be available when calling save_pretrained or push_to_hub. 525 if config is not None and (getattr(instance, "_hub_mixin_config", None) in (None, {})):

File ~/nudt/uni2ts/venv/lib/python3.10/site-packages/huggingface_hub/hub_mixin.py:727, in PyTorchModelHubMixin._from_pretrained(cls, model_id, revision, cache_dir, force_download, proxies, resume_download, local_files_only, token, map_location, strict, **model_kwargs) 710 @classmethod 711 def _from_pretrained( 712 cls, (...) 724 **model_kwargs, 725 ): 726 """Load Pytorch pretrained weights and return the loaded model.""" --> 727 model = cls(**model_kwargs) 728 if os.path.isdir(model_id): 729 print("Loading weights from local directory")

TypeError: MoiraiModule.init() missing 7 required positional arguments: 'distr_output', 'd_model', 'num_layers', 'patch_sizes', 'max_seq_len', 'attn_dropout_p', and 'dropout_p'

Sample-design-alt avatar Jun 06 '24 03:06 Sample-design-alt

when I perform the code in the https://github.com/SalesforceAIResearch/uni2ts/blob/main/example/moirai_forecast.ipynb, there are some error occur. How should I solve this problem?

TypeError Traceback (most recent call last) Cell In[5], line 3 1 # Prepare model 2 model = MoiraiForecast( ----> 3 module=MoiraiModule.from_pretrained( 4 f"Salesforce/moirai-1.0-R-{SIZE}", 5 ), 6 prediction_length=metadata.prediction_length, 7 context_length=CTX, 8 patch_size=PSZ, 9 num_samples=100, 10 target_dim=metadata.target_dim, 11 feat_dynamic_real_dim=metadata.feat_dynamic_real_dim, 12 past_feat_dynamic_real_dim=metadata.past_feat_dynamic_real_dim, 13 ) 15 predictor = model.create_predictor(batch_size=BSZ) 16 forecasts = predictor.predict(test_data.input)

File ~/nudt/uni2ts/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114, in validate_hf_hub_args.._inner_fn(*args, **kwargs) 111 if check_use_auth_token: 112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.name, has_token=has_token, kwargs=kwargs) --> 114 return fn(*args, **kwargs)

File ~/nudt/uni2ts/venv/lib/python3.10/site-packages/huggingface_hub/hub_mixin.py:511, in ModelHubMixin.from_pretrained(cls, pretrained_model_name_or_path, force_download, resume_download, proxies, token, cache_dir, local_files_only, revision, **model_kwargs) 508 if cls._hub_mixin_inject_config: 509 model_kwargs["config"] = config --> 511 instance = cls._from_pretrained( 512 model_id=str(model_id), 513 revision=revision, 514 cache_dir=cache_dir, 515 force_download=force_download, 516 proxies=proxies, 517 resume_download=resume_download, 518 local_files_only=local_files_only, 519 token=token, 520 **model_kwargs, 521 ) 523 # Implicitly set the config as instance attribute if not already set by the class 524 # This way config will be available when calling save_pretrained or push_to_hub. 525 if config is not None and (getattr(instance, "_hub_mixin_config", None) in (None, {})):

File ~/nudt/uni2ts/venv/lib/python3.10/site-packages/huggingface_hub/hub_mixin.py:727, in PyTorchModelHubMixin._from_pretrained(cls, model_id, revision, cache_dir, force_download, proxies, resume_download, local_files_only, token, map_location, strict, **model_kwargs) 710 @classmethod 711 def _from_pretrained( 712 cls, (...) 724 **model_kwargs, 725 ): 726 """Load Pytorch pretrained weights and return the loaded model.""" --> 727 model = cls(**model_kwargs) 728 if os.path.isdir(model_id): 729 print("Loading weights from local directory")

TypeError: MoiraiModule.init() missing 7 required positional arguments: 'distr_output', 'd_model', 'num_layers', 'patch_sizes', 'max_seq_len', 'attn_dropout_p', and 'dropout_p'

This error is caused by not downloading moirai-1.0-R to the local.

catapples avatar Jun 09 '24 13:06 catapples

Hey Were you able to get around it? Any tips how to overcome this?

dany4142 avatar Jul 30 '24 21:07 dany4142

Hi @dany4142 @Sample-design-alt,

Could you provide more info about the issue? Are you trying to load the model trained by yourself?

liu-jc avatar Aug 22 '24 07:08 liu-jc

Hi @Sample-design-alt, have you solved the issue? If so, I will close it. I am not sure if this is caused by model download issue from huggingface. Please check this #91

chenghaoliu89 avatar Dec 04 '24 10:12 chenghaoliu89