在使用GCN网络以及数据集为MUTAG,IMDB-B和PTC-MR进行图分类任务时产生的问题
zhanghaoxuan184 opened this issue · comments
🐛 Bug
To Reproduce
Steps to reproduce the behavior:
在我使用GCN网络以及数据集为MUTAG,IMDB-B和PTC-MR进行图分类任务时,都会产生以下问题
experiment(dataset="mutag", model="gcn", dw="graph_classification_dw", mw="graph_classification_mw",batch_size=16)
MUTAG---ValueError: Expected input batch_size (308) to match target batch_size (16).
IMDB-B---ValueError: Expected input batch_size (289) to match target batch_size (16).
PTC-MR---ValueError: Expected input batch_size (227) to match target batch_size (16).
在我更改batch_size超参数时前面的数字会变得更大,且后面的数字会不一样
experiment(dataset="mutag", model="gcn", dw="graph_classification_dw", mw="graph_classification_mw",batch_size=308)
ValueError: Expected input batch_size (1668) to match target batch_size (94).
Expected behavior
正常运行
Environment
- CogDL version:0.5.3
- OS (e.g., Linux):Windows 10
- Python version:3.8.13
- PyTorch version:1.12.1
- CUDA/cuDNN version:11.6
- Software:Pycharm
其中报错为:
Namespace(activation='relu', actnn=False, batch_size=308, checkpoint_path='./checkpoints/model.pt', cpu=False, cpu_inference=False, dataset=['mutag'], degree_node_features=False, devices=[0], distributed=False, do_test=True, do_valid=True, dropout=0.5, dw='graph_classification_dw', epochs=500, eval_step=1, fp16=False, hidden_size=64, load_emb_path=None, local_rank=0, log_path='.', logger=None, lr=0.01, master_addr='localhost', master_port=13425, max_epoch=None, model=['gcn'], mw='graph_classification_mw', n_trials=3, n_warmup_steps=0, norm=None, nstage=1, num_classes=None, num_features=None, num_layers=2, patience=100, progress_bar='epoch', project='cogdl-exp', residual=False, resume_training=False, return_model=False, rp_ratio=1, save_emb_path=None, seed=[1], split=[0], test_ratio=0.3, train_ratio=0.5, unsup=False, use_best_config=False, weight_decay=0)
|-------------------------------------------------------------------------------------------|
*** Running (mutag , gcn , graph_classification_dw , graph_classification_mw ) |
---|
Model Parameters: 642 |
0% |
warnings.warn(f'Error checking compiler version for {compiler}: {error}') |
��Ϣ: ���ṩ��ģʽ���ҵ��ļ��� |
C:\Users\Administrator\Anaconda\envs\pytorch_gpu\lib\site-packages\torch\utils\cpp_extension.py:346: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。 |
warnings.warn(f'Error checking compiler version for {compiler}: {error}') |
��Ϣ: ���ṩ��ģʽ���ҵ��ļ��� |
C:\Users\Administrator\Anaconda\envs\pytorch_gpu\lib\site-packages\torch\utils\cpp_extension.py:346: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。 |
warnings.warn(f'Error checking compiler version for {compiler}: {error}') |
��Ϣ: ���ṩ��ģʽ���ҵ��ļ��� |
C:\Users\Administrator\Anaconda\envs\pytorch_gpu\lib\site-packages\torch\utils\cpp_extension.py:346: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。 |
warnings.warn(f'Error checking compiler version for {compiler}: {error}') |
��Ϣ: ���ṩ��ģʽ���ҵ��ļ��� |
��Ϣ: ���ṩ��ģʽ���ҵ��ļ��� |
��Ϣ: ���ṩ��ģʽ���ҵ��ļ��� |
0% |
Traceback (most recent call last): |
File "D:/cogdl-master/myGNN.py", line 5, in |
experiment(dataset="mutag", model="gcn", dw="graph_classification_dw", mw="graph_classification_mw",batch_size=308)
File "D:\cogdl-master\cogdl\experiments.py", line 360, in experiment
return raw_experiment(args)
File "D:\cogdl-master\cogdl\experiments.py", line 264, in raw_experiment
results = [train(args) for args in variant_args_generator(args, variants)]
File "D:\cogdl-master\cogdl\experiments.py", line 264, in
results = [train(args) for args in variant_args_generator(args, variants)]
File "D:\cogdl-master\cogdl\experiments.py", line 218, in train
result = trainer.run(model_wrapper, dataset_wrapper)
File "D:\cogdl-master\cogdl\trainer\trainer.py", line 204, in run
self.train(self.devices[0], model_w, dataset_w)
File "D:\cogdl-master\cogdl\trainer\trainer.py", line 361, in train
training_loss = self.train_step(model_w, train_loader, optimizers, lr_schedulers, rank, scaler)
File "D:\cogdl-master\cogdl\trainer\trainer.py", line 515, in train_step
loss = model_w.on_train_step(batch)
File "D:\cogdl-master\cogdl\wrappers\model_wrapper\base_model_wrapper.py", line 73, in on_train_step
return self.train_step(*args, **kwargs)
File "D:\cogdl-master\cogdl\wrappers\model_wrapper\graph_classification\graph_classification_mw.py", line 15, in train_step
loss = self.default_loss_fn(pred, y)
File "D:\cogdl-master\cogdl\utils\evaluator.py", line 121, in call
return torch.nn.functional.nll_loss(y_pred, y_true)
File "C:\Users\Administrator\Anaconda\envs\pytorch_gpu\lib\site-packages\torch\nn\functional.py", line 2689, in nll_loss
return torch._C._nn.nll_loss_nd(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
ValueError: Expected input batch_size (1668) to match target batch_size (94).
Process finished with exit code 1
Hi @zhanghaoxuan184 ,
感谢对cogdl的关注。您能否先测试一下gin模型能否使用?gcn模型目前主要用于节点分类任务
gin模型可以使用,非常感谢您!请问cogdl当中的哪些模型可以进行图分类任务
GNN模型应该是这些:["gin", "patchy_san", "diffpool", "infograph", "dgcnn", "sortpool"]
embedding模型应该是这些:["dgk","graph2vec"]
好的,非常感谢!!