Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to feed model batch inputs ? #21

Open
ChenHuaYou opened this issue Apr 5, 2021 · 3 comments
Open

how to feed model batch inputs ? #21

ChenHuaYou opened this issue Apr 5, 2021 · 3 comments

Comments

@ChenHuaYou
Copy link

hi, how can i feed the model batch inputs ? i just know how to feed one audio to the model,but if i want to feed batch?can you tell me ? thanks.

@singhal2
Copy link

+1

@Chevalier1024
Copy link

Chevalier1024 commented Jul 12, 2021

hi bros, I feed model batch inputs through the following steps.

  1. just save the results of vggish_input.wavfile_to_examples() on your dataset.
  2. finetune model
class FintuneModel(nn.Module):
    def __init__(self):
        super(FintuneModel, self).__init__()
        urls = {
            'vggish': "https://github.com/harritaylor/torchvggish/releases/download/v0.1/vggish-10086976.pth"
        }
        self.pretrain = vggish.VGGish(urls, preprocess=False, postprocess=False)
        self.classifier = classifier()

    def forward(self, x):
        """
        :param x: [bs, num_frames, 96, 64]
        :return:
        """
        bs, num_frames, _, _ = x.size()
        x = x.view(bs*num_frames, 1, x.size(2), x.size(3))
        x = self.pretrain(x) # [bs*num_frames, 128]
        x = x.view(bs, x.size(1), num_frames)
        x = self.classifier(x)
        return x

@ifeelagood
Copy link

@Chevalier1024 so each batch has a different number of samples?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants