mpc001 / auto_avsr

Auto-AVSR: Lip-Reading Sentences Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`cut_or_pad` function is wrong

xiabingquan opened this issue · comments

The current version is:

def cut_or_pad(data, size, dim=0):
    if data.size(dim) < size:
        padding = size - data.size(dim)
        data = torch.nn.functional.pad(data, (0, padding), "constant")
    elif data.size(dim) > size:
        data = data[:size]
    assert data.size(dim) == size
    return data

The right version should be:

def cut_or_pad(data, size, dim=0):
    if data.size(dim) < size:
        padding = size - data.size(dim)
        data = torch.nn.functional.pad(data, (0, 0, 0, padding), "constant")           # modified
        size = data.size(dim)                                                          # added
    elif data.size(dim) > size:
        data = data[:size]
    assert data.size(dim) == size
    return data

Hi @xiabingquan, the bug has been fixed. Thank you!

def cut_or_pad(data, size, dim=0):
    if data.size(dim) < size:
        padding = size - data.size(dim)
        data = torch.nn.functional.pad(data, (0, 0, 0, padding), "constant")           # modified
        size = data.size(dim)                                                          # added
    elif data.size(dim) > size:
        data = data[:size]
    assert data.size(dim) == size
    return data

Does this problem affect the accuracy?

def cut_or_pad(data, size, dim=0):
    if data.size(dim) < size:
        padding = size - data.size(dim)
        data = torch.nn.functional.pad(data, (0, 0, 0, padding), "constant")           # modified
        size = data.size(dim)                                                          # added
    elif data.size(dim) > size:
        data = data[:size]
    assert data.size(dim) == size
    return data

Does this problem affect the accuracy?

In my case, it raises errors if not modified.

def cut_or_pad(data, size, dim=0):
    if data.size(dim) < size:
        padding = size - data.size(dim)
        data = torch.nn.functional.pad(data, (0, 0, 0, padding), "constant")           # modified
        size = data.size(dim)                                                          # added
    elif data.size(dim) > size:
        data = data[:size]
    assert data.size(dim) == size
    return data

Does this problem affect the accuracy?

In my case, it raises errors if not modified.

What kind of error is the error you mentioned?
Is it an error that the code itself does not execute?