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

Cannot running GNN+Transformer model #152

Open
yrq3027 opened this issue Oct 13, 2022 · 3 comments
Open

Cannot running GNN+Transformer model #152

yrq3027 opened this issue Oct 13, 2022 · 3 comments

Comments

@yrq3027
Copy link

yrq3027 commented Oct 13, 2022

Hi,
This error happened only in GNN+Transformer model.

Let's use 1 GPU!
--- Data Preparation ---
--- Go for Training ---
Traceback (most recent call last):
File "Pharos_DeepPurpose_ATFP_clf_demo.py", line 103, in
trainModel(coding)
File "Pharos_DeepPurpose_ATFP_clf_demo.py", line 96, in trainModel
model.train(train, val, test)
File "/home/data/aidd/DeepPurpose/DeepPurpose/DTI.py", line 436, in train
score = self.model(v_d, v_p)
File "/home/AIDD/anaconda3/envs/DeepPurpose/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/home/data/aidd/DeepPurpose/DeepPurpose/DTI.py", line 52, in forward
v_f = torch.cat((v_D, v_P), 1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 512 but got size 2 for tensor number 1 in the list.

@kexinhuang12345
Copy link
Owner

Could you send code to reproduce error?

@yrq3027
Copy link
Author

yrq3027 commented Jan 5, 2023

Thank you for reply. I definited my own dataset, also ,the same error happened when I run the benchmark dataset.
import os
import pandas as pd
import numpy as np
os.environ['CUDA_VISIBLE_DEVICES'] = "1"

import DeepPurpose.DTI as models
from DeepPurpose.utils import *
from DeepPurpose.dataset import *
from DeepPurpose import utils, DTI, dataset

CODING_TYPE = ["0"]

def dataLoader():

X_drugs, X_targets, y = dataset.load_Pharos(binary=True)
return X_drugs, X_targets, y

def createModel(coding):

X_drugs, X_targets, y = dataLoader()

if coding == "0":
    
    drug_encoding = 'DGL_GIN_AttrMasking'
    target_encoding = 'transformer'
    train, val, test = utils.data_process(X_drugs, X_targets, y, 
                            drug_encoding, target_encoding, 
                            split_method='random',frac=[0.7,0.1,0.2],
                            random_seed = 1)
    config = utils.generate_config(drug_encoding = drug_encoding, 
                     target_encoding = target_encoding, 
                     cls_hidden_dims = [1024,1024,512], 
                     train_epoch = 150, 
                     LR = 0.001, 
                     batch_size = 512,
                     hidden_dim_drug = 128,
                     mpnn_hidden_size = 128,
                     mpnn_depth = 3, 
                     cnn_target_filters = [32,64,96],
                     cnn_target_kernels = [4,8,12]
                    )
    model = models.model_initialize(**config)


return train, val, test, drug_encoding, target_encoding, model

def trainModel(coding):

train, val, test, drug_encoding, target_encoding, model = createModel(coding)
model.train(train, val, test)
model.save_model('./Pharos_model/'+drug_encoding+"-"+target_encoding+"_clf")

if name == "main":

for coding in CODING_TYPE:
    
    trainModel(coding)

@kexinhuang12345
Copy link
Owner

Are you using multiple GPUs? could you try a single GPU? also, does other combination work?

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

2 participants