audio_zen/inferencer/base_inferencer.py
def _unfold(input, pad_mode, n_neighbor):
        """
        Along the frequency axis, to divide the spectrogram into multiple overlapped sub band.

        Args:
            input: [B, C, F, T]

        Returns:
            [B, N, C, F, T], F is the number of frequency of the sub band unit, e.g., [2, 161, 1, 19, 200]
        """
        assert input.dim() == 4, f"The dim of input is {input.dim()}, which should be 4."
        batch_size, n_channels, n_freqs, n_frames = input.size()
        output = input.reshape(batch_size * n_channels, 1, n_freqs, n_frames)
        sub_band_n_freqs = n_neighbor * 2 + 1

        output = functional.pad(output, [0, 0, n_neighbor, n_neighbor], mode=pad_mode)
        output = functional.unfold(output, (sub_band_n_freqs, n_frames))
        assert output.shape[-1] == n_freqs, f"n_freqs != N (sub_band), {n_freqs} != {output.shape[-1]}"

        # Split the middle dimensions of the unfolded features
        output = output.reshape(batch_size, n_channels, sub_band_n_freqs, n_frames, n_freqs)
        output = output.permute(0, 4, 1, 2, 3).contiguous()  # permute 本质上与  reshape 可是不同的 ...，得到的维度相同，但 entity 不同啊
        return output

        Along the frequency axis, to divide the spectrogram into multiple overlapped sub band.

        Args:
            input: [B, C, F, T]

        Returns:
            [B, N, C, F, T], F is the number of frequency of the sub band unit, e.g., [2, 161, 1, 19, 200]
        
Along the frequency axis, to divide the spectrogram into multiple overlapped sub band.
Along the frequency axis to divide the spectrogram into multiple overlapped sub band .
def _unfold(input, pad_mode, n_neighbor):
        assert input.dim() == 4, f"The dim of input is {input.dim()}, which should be 4."
        batch_size, n_channels, n_freqs, n_frames = input.size()
        output = input.reshape(batch_size * n_channels, 1, n_freqs, n_frames)
        sub_band_n_freqs = n_neighbor * 2 + 1
        output = functional.pad(output, [0, 0, n_neighbor, n_neighbor], mode=pad_mode)
        output = functional.unfold(output, (sub_band_n_freqs, n_frames))
        assert output.shape[-1] == n_freqs, f"n_freqs != N (sub_band), {n_freqs} != {output.shape[-1]}"
        output = output.reshape(batch_size, n_channels, sub_band_n_freqs, n_frames, n_freqs)
        output = output.permute(0, 4, 1, 2, 3).contiguous()  
        return output
def _unfold ( input , pad_mode , n_neighbor ) : assert input . dim ( ) == 4 , f"The dim of input is {input.dim()}, which should be 4." batch_size , n_channels , n_freqs , n_frames = input . size ( ) output = input . reshape ( batch_size * n_channels , 1 , n_freqs , n_frames ) sub_band_n_freqs = n_neighbor * 2 + 1 output = functional . pad ( output , [ 0 , 0 , n_neighbor , n_neighbor ] , mode = pad_mode ) output = functional . unfold ( output , ( sub_band_n_freqs , n_frames ) ) assert output . shape [ - 1 ] == n_freqs , f"n_freqs != N (sub_band), {n_freqs} != {output.shape[-1]}" output = output . reshape ( batch_size , n_channels , sub_band_n_freqs , n_frames , n_freqs ) output = output . permute ( 0 , 4 , 1 , 2 , 3 ) . contiguous ( ) return output
Along the frequency axis, to divide the spectrogram into multiple overlapped sub band.
Along the frequency axis to divide the spectrogram into multiple overlapped sub band .
"""
        Along the frequency axis, to divide the spectrogram into multiple overlapped sub band.

        Args:
            input: [B, C, F, T]

        Returns:
            [B, N, C, F, T], F is the number of frequency of the sub band unit, e.g., [2, 161, 1, 19, 200]
        """ # Split the middle dimensions of the unfolded features # permute 本质上与  reshape 可是不同的 ...，得到的维度相同，但 entity 不同啊
None
input
None
pad_mode
n_neighbor