RuntimeError: Sizes of tensors
Hello, when i run the InSilicoPerturber
function to do gene perturbation.
code is:
isp = InSilicoPerturber(perturb_type="delete",
perturb_rank_shift=None,
genes_to_perturb=perturb_gene_list,
combos=0,
anchor_gene=None,
model_type="CellClassifier",#Pretrained
num_classes=3,
emb_mode="cell",
cell_emb_style="mean_pool",
filter_data={"cell_type":["Cardiomyocyte1","Cardiomyocyte2","Cardiomyocyte3"]},
cell_states_to_model={"disease":(["nf"],["hcm"],["dcm"])},
max_ncells=None,
emb_layer=0,
forward_batch_size=4,
nproc=16,
save_raw_data=False)
isp.perturb_data("/cell_disease/230627_geneformer_CellClassifier_L2048_B4_LR5e-05_LSlinear_WU500_E10_Oadamw_F0/",
dataset,
"/cell_classification/test_silico_all/",
out_f)
ERROR is:
File ~/anaconda3/envs/shiny_py38/lib/python3.8/site-packages/geneformer/in_silico_perturber.py:262, in quant_cos_sims(model, perturb_type, perturbation_batch, forward_batch_size, layer_to_quant, original_emb, indices_to_perturb, cell_states_to_model, state_embs_dict)
260 else:
261 for state in possible_states:
--> 262 cos_sims_vs_alt_dict[state] = torch.cat(cos_sims_vs_alt_dict[state])
263 return cos_sims_vs_alt_dict
RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 1 but got size 2047 for tensor number 76 in the list.
The latest information
The same error is reported when the genes_to_perturb parameter is set to all
(closing due to duplicate discussion)