torchvggish icon indicating copy to clipboard operation
torchvggish copied to clipboard

how to feed model batch inputs ?

Open ChenHuaYou opened this issue 3 years ago • 3 comments

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.

ChenHuaYou avatar Apr 05 '21 01:04 ChenHuaYou

+1

singhal2 avatar Apr 10 '21 11:04 singhal2

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

Chevalier1024 avatar Jul 12 '21 09:07 Chevalier1024

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

ifeelagood avatar Feb 13 '23 09:02 ifeelagood