MCPcopy Index your code
hub / github.com/shiyu-coder/Kronos / encode

Method encode

model/kronos.py:142–159  ·  view source on GitHub ↗

Encodes the input data into quantized indices. Args: x (torch.Tensor): Input tensor of shape (batch_size, seq_len, d_in). half (bool, optional): Whether to use half quantization in BSQuantizer. Defaults to False. Returns: torch.Tensor: Q

(self, x, half=False)

Source from the content-addressed store, hash-verified

140 return x
141
142 def encode(self, x, half=False):
143 """
144 Encodes the input data into quantized indices.
145
146 Args:
147 x (torch.Tensor): Input tensor of shape (batch_size, seq_len, d_in).
148 half (bool, optional): Whether to use half quantization in BSQuantizer. Defaults to False.
149
150 Returns:
151 torch.Tensor: Quantized indices from BSQuantizer.
152 """
153 z = self.embed(x)
154 for layer in self.encoder:
155 z = layer(z)
156 z = self.quant_embed(z)
157
158 bsq_loss, quantized, z_indices = self.tokenizer(z, half=half, collect_metrics=False)
159 return z_indices
160
161 def decode(self, x, half=False):
162 """

Callers 3

train_modelFunction · 0.80
train_modelFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected