Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bulktb.vae_train function error #166

Open
WeiQin2001 opened this issue Sep 26, 2024 · 0 comments
Open

bulktb.vae_train function error #166

WeiQin2001 opened this issue Sep 26, 2024 · 0 comments

Comments

@WeiQin2001
Copy link

I run the following code:
#Configure the BulkTrajBlend model
#要求输入的bulk数据和scRNA数据都得是counts
bulktb=ov.bulk2single.BulkTrajBlend(bulk_seq=bulk_data,
single_seq=adata_counts,
# bulk_group=['dg_d_1','dg_d_2','dg_d_3'],
celltype_key='scsa_celltype_cellmarker',)

bulktb.vae_configure(cell_target_num=None) #the key of this error, but I can not understand the reason

vae_net=bulktb.vae_train(
batch_size=512,
learning_rate=1e-4,
hidden_size=256,
epoch_num=3500,
vae_save_dir='./output',
vae_save_name='TED_PBMC_vae',
generate_save_dir='./output',
generate_save_name='TED_PBMC_vae_generate')

the following error will be found:

AssertionError Traceback (most recent call last)
Cell In[33], line 4
1 #Training the beta-VAE model
2
3 #这里老报错
----> 4 vae_net=bulktb.vae_train(
5 batch_size=512,
6 learning_rate=1e-4,
7 hidden_size=256,
8 epoch_num=3500,
9 vae_save_dir='./output',
10 vae_save_name='TED_PBMC_vae',
11 generate_save_dir='./output',
12 generate_save_name='TED_PBMC_vae_generate')

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/omicverse/bulk2single/_bulktrajblend.py:154, in BulkTrajBlend.vae_train(self, vae_save_dir, vae_save_name, generate_save_dir, generate_save_name, batch_size, learning_rate, hidden_size, epoch_num, patience, save)
127 def vae_train(self,
128 vae_save_dir:str='save_model',
129 vae_save_name:str='vae',
(...)
135 epoch_num:int=5000,
136 patience:int=50,save:bool=True):
137 r"""
138 Train the VAE model of BulkTrajBlend.
139
(...)
151
152 """
--> 154 self.vae_net=self.vae_model.train(
155 batch_size=batch_size,
156 learning_rate=learning_rate,
157 hidden_size=hidden_size,
158 epoch_num=epoch_num,
159 vae_save_dir=vae_save_dir,
160 vae_save_name=vae_save_name,
161 generate_save_dir=generate_save_dir,
162 generate_save_name=generate_save_name,
163 patience=patience,save=save)

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/omicverse/bulk2single/_bulk2single.py:181, in Bulk2Single.train(self, vae_save_dir, vae_save_name, generate_save_dir, generate_save_name, batch_size, learning_rate, hidden_size, epoch_num, patience, save)
178 if self.input_data==None:
179 self.prepare_input()
180 single_cell, label, breed_2_list, index_2_gene, cell_number_target_num,
--> 181 nclass, ntrain, feature_size = self.__get_model_input(self.input_data, self.cell_target_num)
182 print('...begin vae training')
183 vae_net,history = train_vae(single_cell,
184 label,
185 self.used_device,
(...)
190 hidden_size=hidden_size,
191 patience=patience,)

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/omicverse/bulk2single/_bulk2single.py:366, in Bulk2Single.__get_model_input(self, data, cell_target_num)
364 # FeaSize = single_cell.shape[1]
365 feature_size = single_cell.shape[1]
--> 366 assert nclass == len(cell_target_num.keys()), "cell type num no match!!!"
368 for i in range(len(breed_set)):
369 dic[breed_2_list[i]] = i

AssertionError: cell type num no match!!!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant