Skip to content

Module 'ModuleDict' has no attribute 'similarity' #26

@linzqin

Description

@linzqin

Hi @peikexin9

When I try to get the function similarity by running python command/inference/get_embedding.py, I got two errors.

  1. The first error occurs in trex.py line 123
 @classmethod
    def setup_task(cls, args, **kwargs):
        # paths = utils.split_paths(args.data)

        paths = os.listdir(args.data)
        assert len(paths) > 0
        if len(paths) != len(configs.fields):
            print('ERROR: invalid paths:', paths)
            raise ValueError()

Code discovery: the length of paths at paths = os.listdir('data-bin/similarity') is required to be equal to configs.fields. But the paths under paths are input0, input1, label, and it is the subdirectory lengths of input0 and input1 that are equal to configs.fileds. data-bin/similarity related content generation is in command/finetune/preprocess preprocess.py, there is nothing wrong with the directory structure, So I chose to replace data-bin/similarity with data-bin/similarity/input0 in get_embedding.py and skipped this error. I don't know if this is the correct processing.

  1. The second error is that when I continue to run to trex_script = torch.jit.script(trex.model), I get an error: Exception: RuntimeError Module 'ModuleDict' has no attribute 'similarity' in model.py line 238.
if classification_head_name is not None:
            x = {
                'features': self.classification_heads.similarity(x['features'])
            }
        return x, extra

I Check the ModuleDict manual. Indeed there is no such attribute.Also, have no attributes like similarity_pair.

def similarity_pair(self, concat_in: torch.Tensor):
        return self.classification_heads.similarity_pair(concat_in)

The Pytorch version is 1.13.1.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions