sinhat98/adapter-wavlm

I got 'dict' object has no attribute 'to'

hwopark opened this issue · 1 comments

When I run the code for ASV examples, I got error ('dict' object has no attribute 'to) because of inputs is dict of tensors.

Are there any alternatives?

inputs = inputs.to(device)

@hwopark
Sorry for the delay in replying.
The code contains a bug as you have pointed out.
Please use the following function

def to_device(inputs: dict, decice: str = 'cuda') -> dict:.
    for k, v in inputs.items():
        if isinstance(v, torch.Tensor):.
            inputs[k] = v.to(device)
    return inputs