Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added docs/.DS_Store
Binary file not shown.
Binary file added scarches/.DS_Store
Binary file not shown.
Binary file added scarches/models/.DS_Store
Binary file not shown.
10 changes: 6 additions & 4 deletions scarches/models/scpoli/scpoli_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,15 @@ def get_latent(
for batch in subsampled_indices:
x_batch = x[batch, :]
if sparse.issparse(x_batch):
batch = batch.cpu().numpy() # IMPORTANT: Convert to NumPy array
x_batch = x_batch.toarray()
x_batch = torch.tensor(x_batch, device=device).float()
latent = self.model.get_latent(
x_batch, c[batch, :], mean
)
latents += [latent.cpu().detach()]
latents = torch.cat(latents)
# latents = torch.cat(latents) # MODIFY THIS
latents = torch.cat(latents).cpu().numpy() # Convert to NumPy after concatenation
return np.array(latents)

def get_conditional_embeddings(self):
Expand Down Expand Up @@ -478,7 +480,7 @@ def classify(
for batch in subsampled_indices:
if prototype: # classify prototypes used for unseen cell type
pred, prob, weighted_distance = self.model.classify(
x[batch, :].to(device),
x[batch, :].to(device, dtype=torch.float32), # add dtype
prototype=prototype,
classes_list=prototypes_idx,
p=p,
Expand All @@ -487,8 +489,8 @@ def classify(
)
else: # default routine, classify cell by cell
pred, prob, weighted_distance = self.model.classify(
x[batch, :].to(device),
c[batch].to(device),
x[batch, :].to(device, dtype=torch.float32), # add dtype
c[batch].to(device, dtype=torch.float32), # add dtype
prototype=prototype,
classes_list=prototypes_idx,
p=p,
Expand Down