Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoGrin committed Feb 4, 2025
1 parent 2a22cb2 commit 6f9ce90
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tabpfn/model/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,20 @@ def select_features(x: torch.Tensor, sel: torch.Tensor) -> torch.Tensor:
# If B == 1, we don't need to append zeros, as the number of features don't need to be fixed.
if B == 1:
return x[:, :, sel[0]]

new_x = torch.zeros((batch_size, B, total_features), device=x.device, dtype=x.dtype)

# For each block, compute the number of selected features.
sel_counts = sel.sum(dim=-1) # shape: (B,)

for b in range(B):
s = int(sel_counts[b])
if s > 0:
new_x[:, b, :s] = x[:, b, sel[b]]

return new_x


def remove_outliers(
X: torch.Tensor,
n_sigma: float = 4,
Expand Down

0 comments on commit 6f9ce90

Please sign in to comment.