sinhat98 / adapter-wavlm

MIT License
37 stars 9 forks source link

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

Open hwopark opened 8 months ago

hwopark commented 8 months ago

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?

https://github.com/sinhat98/adapter-wavlm/blob/4226ea86793e2487ff6b3b5941c9a4284eb16194/ASV/utils.py#L237

sinhat98 commented 8 months ago

@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