Ejemplo n.º 1
0
    def __init__(self, avg=.9998):
        super(Model, self).__init__()
        # Getting Mel Spectrogram on the fly
        self.mel_layer = Spectrogram.MelSpectrogram(sr=fs,
                                                    n_fft=n_fft,
                                                    n_mels=n_mels,
                                                    htk=htk,
                                                    fmin=50,
                                                    fmax=6000,
                                                    center=center)

        # Creating Layers
        self.linear = torch.nn.Linear(n_mels * regions, m, bias=False)
        torch.nn.init.constant_(self.linear.weight, 0)  # initialize

        self.avg = avg
    def __init__(self, avg=.9998):
        super(Model, self).__init__()
        # Getting Mel Spectrogram on the fly
        self.spec_layer = Spectrogram.MelSpectrogram(sr=fs, n_fft=n_fft, n_mels=n_mels, htk=htk, fmin=50, fmax=6000, center=center)
            
        # Creating Layers
        self.CNN_freq_kernel_size=(128,1)
        self.CNN_freq_kernel_stride=(2,1)
        k_out = 128
        k2_out = 256
        
        self.CNN_freq = nn.Conv2d(1,k_out,
                                kernel_size=self.CNN_freq_kernel_size,stride=self.CNN_freq_kernel_stride)
        self.CNN_time = nn.Conv2d(k_out,k2_out,
                                kernel_size=(1,regions),stride=(1,1))    
        
        self.region_v = 1 + (n_mels-self.CNN_freq_kernel_size[0])//self.CNN_freq_kernel_stride[0]
        self.linear = torch.nn.Linear(k2_out*self.region_v, m, bias=False)

        self.avg = avg