espnet2.speechlm.tokenizer.random_tokenizer.RandomProjectionQuantizer
Less than 1 minute
espnet2.speechlm.tokenizer.random_tokenizer.RandomProjectionQuantizer
class espnet2.speechlm.tokenizer.random_tokenizer.RandomProjectionQuantizer(dim, codebook_size, codebook_dim, norm=True)
Bases: Module
Initializes internal Module state, shared by both nn.Module and ScriptModule.
forward(x: Tensor) → Tensor
Perform random projection and quantization.
- Parameters:x (torch.Tensor) – Input tensor with shape (B, L, D).
- Returns: Output tensor of shape (B, L) containing quantized indices.
- Return type: torch.Tensor