Skip to content

Problem loading model state #97

@amilton-reis

Description

@amilton-reis

Hi,

I'm trying using the .load_state() function, but the result is:

TypeError Traceback (most recent call last)
in
1 model_t = dm.MatchingModel(attr_summarizer="hybrid")
----> 2 model_t.load_state("model_1.pth")

/local_disk0/.ephemeral_nfs/envs/pythonEnv-33cf32f5-60db-4ff5-acdf-2c87c014459e/lib/python3.8/site-packages/deepmatcher/models/core.py in load_state(self, path, map_location)
479 MatchingDataset.finalize_metadata(train_info)
480
--> 481 self.initialize(train_info, self.state_meta.init_batch)
482
483 self.load_state_dict(state['model'])

/local_disk0/.ephemeral_nfs/envs/pythonEnv-33cf32f5-60db-4ff5-acdf-2c87c014459e/lib/python3.8/site-packages/deepmatcher/models/core.py in initialize(self, train_dataset, init_batch)
353 sort_in_buckets=False)
354 init_batch = next(run_iter.iter())
--> 355 self.forward(init_batch)
356
357 # Keep this init_batch for future initializations.

/local_disk0/.ephemeral_nfs/envs/pythonEnv-33cf32f5-60db-4ff5-acdf-2c87c014459e/lib/python3.8/site-packages/deepmatcher/models/core.py in forward(self, input)
417 for name in self.meta.all_text_fields:
418 attr_input = getattr(input, name)
--> 419 embeddings[name] = self.embedname
420
421 attr_comparisons = []

/local_disk0/.ephemeral_nfs/envs/pythonEnv-33cf32f5-60db-4ff5-acdf-2c87c014459e/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
887 result = self._slow_forward(*input, **kwargs)
888 else:
--> 889 result = self.forward(*input, **kwargs)
890 for hook in itertools.chain(
891 _global_forward_hooks.values(),

/local_disk0/.ephemeral_nfs/envs/pythonEnv-33cf32f5-60db-4ff5-acdf-2c87c014459e/lib/python3.8/site-packages/deepmatcher/models/modules.py in forward(self, *args)
185 module_args.append(arg.data if isinstance(arg, AttrTensor) else arg)
186
--> 187 results = self.module(*module_args)
188
189 if not isinstance(args[0], AttrTensor):

/local_disk0/.ephemeral_nfs/envs/pythonEnv-33cf32f5-60db-4ff5-acdf-2c87c014459e/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
887 result = self._slow_forward(*input, **kwargs)
888 else:
--> 889 result = self.forward(*input, **kwargs)
890 for hook in itertools.chain(
891 _global_forward_hooks.values(),

/local_disk0/.ephemeral_nfs/envs/pythonEnv-33cf32f5-60db-4ff5-acdf-2c87c014459e/lib/python3.8/site-packages/torch/nn/modules/sparse.py in forward(self, input)
143
144 def forward(self, input: Tensor) -> Tensor:
--> 145 return F.embedding(
146 input, self.weight, self.padding_idx, self.max_norm,
147 self.norm_type, self.scale_grad_by_freq, self.sparse)

/local_disk0/.ephemeral_nfs/envs/pythonEnv-33cf32f5-60db-4ff5-acdf-2c87c014459e/lib/python3.8/site-packages/torch/nn/functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse)
1911 # remove once script supports set_grad_enabled
1912 no_grad_embedding_renorm(weight, input, max_norm, norm_type)
-> 1913 return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
1914
1915

TypeError: embedding(): argument 'indices' (position 2) must be Tensor, not AttrTensor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions