Skip to content

ValueError in loading_GNN  #5

Description

@HideshiOoka

I am having trouble with loading_GNN. Could you kindly provide me with assistance?

Input code block from Tutorial KM prediction.ipynb:

from KM_prediction import *
KM_prediction(substrate_list = ["C"], enzyme_list = ["KM"])

Output:

Step 1/3: Calculating numerical representations for all metabolites.
.....1(a) Calculating input matrices for Graph Neural Network
.....1(b) Calculating numerical metabolite representations using a Graph Neural Network
[17:18:54] ERROR: 
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[5], [line 2](vscode-notebook-cell:?execution_count=5&line=2)
      [1](vscode-notebook-cell:?execution_count=5&line=1) from KM_prediction import *
----> [2](vscode-notebook-cell:?execution_count=5&line=2) KM_prediction(substrate_list = ["C"], enzyme_list = ["KM"])
      [4](vscode-notebook-cell:?execution_count=5&line=4) # KM_prediction(substrate_list = ["InChI=1S/C21H27N7O14P2/c22-17-12-19(25-7-24-17)28(8-26-12)21-16(32)14(30)11(41-21)6-39-44(36,37)42-43(34,35)38-5-10-13(29)15(31)20(40-10)27-3-1-2-9(4-27)18(23)33/h1-4,7-8,10-11,13-16,20-21,29-32H,5-6H2,(H5-,22,23,24,25,33,34,35,36,37)/p-1/t10-,11-,13-,14-,15-,16-,20-,21-/m1/s1"], 
      [5](vscode-notebook-cell:?execution_count=5&line=5) #             enzyme_list = ["MSIPETQKGVIFYESHGKLEYKDIPVPKPKANELLINVKYSGVCHTDLHAWHGDWPLPVKLPLVGGHEGAGVVVGMGENVKWKIGDYAGIKWLNGSCMACEYCELGNESNCPHADLSGYTHDGSFQQYATADAVQAAHIPQGTDLAQVAPILCAGITVYKALKSANLMAGHWVAISGAAGGLGSLAVQYAKAMGYRVLGIDGGEGKEELFRSIGGEVFIDFTKEKDIVGAVLKATDGGAHGVINVSVSEAAIEASTRYVRANGTTVLVGMPAGAKCCSDVFNQVVKSISIVGSYVGNRADTREALDFFARGLVKSPIKVVGLSTLPEIYEKMEKGQIVGRYVVDTSK"])

File c:\Users\Hideshi_Ooka\Research\Projects\DL_Km_kcat\Km_prediction_function\code\KM_prediction.py:23, in KM_prediction(substrate_list, enzyme_list)
     [21](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/KM_prediction.py:21) df_met = metabolite_preprocessing(metabolite_list = substrate_list)
     [22](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/KM_prediction.py:22) print(".....1(b) Calculating numerical metabolite representations using a Graph Neural Network")
---> [23](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/KM_prediction.py:23) df_met = calculate_gnn_representations(df_met)
     [24](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/KM_prediction.py:24) #remove temporary metabolite directory:
     [25](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/KM_prediction.py:25) shutil.rmtree(join(CURRENT_DIR, "..", "data", "temp_met"))

File c:\Users\Hideshi_Ooka\Research\Projects\DL_Km_kcat\Km_prediction_function\code\GNN_functions.py:26, in calculate_gnn_representations(df_met)
     [24](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/GNN_functions.py:24) def calculate_gnn_representations(df_met):
     [25](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/GNN_functions.py:25) 	N_max = np.max(df_met["number_atoms"].loc[df_met["successfull"]]) + 1
---> [26](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/GNN_functions.py:26) 	GNN_representation_fct = loading_GNN(N_max)
     [27](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/GNN_functions.py:27) 	df_valid_met = df_met.loc[df_met["successfull"]]
     [28](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/GNN_functions.py:28) 	df_invalid_met = df_met.loc[~df_met["successfull"]]

File c:\Users\Hideshi_Ooka\Research\Projects\DL_Km_kcat\Km_prediction_function\code\GNN_functions.py:38, in loading_GNN(N_max)
     [36](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/GNN_functions.py:36) def loading_GNN(N_max):
     [37](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/GNN_functions.py:37) 	batch_size, D, learning_rate, epochs, l2_reg_fc, l2_reg_conv, rho = 64, 50, 0.05, 50, 1, 0.01, 0.95 
...
        return tf_fn(x)

x = MyLayer()(x)

I believe the error is due to tf.multiply(H0, A_in), because when I run the DMPNN row by row, this row gave me the same ValueError.

As a side note, prior to encountering the error above, I changed:

Extras_in = Input(2, name ="Extras", dtype='float32')

to

Extras_in = Input(shape=(2,), name ="Extras", dtype='float32')

because of a different ValueError:

File c:\Users\Hideshi_Ooka\Research\Projects\DL_Km_kcat\Km_prediction_function\code\GNN_functions.py:38, in loading_GNN(N_max)
     [36](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/GNN_functions.py:36) def loading_GNN(N_max):
     [37](file:///C:/Users/Hideshi_Ooka/Research/Projects/DL_Km_kcat/Km_prediction_function/code/GNN_functions.py:37) 	batch_size, D, learning_rate, epochs, l2_reg_fc, l2_reg_conv, rho = 64, 50, 0.05, 50, 1, 0.01, 0.95 
...
    [532](file:///C:/Users/Hideshi_Ooka/AppData/Local/Programs/Python/Python312/Lib/site-packages/keras/src/backend/common/variables.py:532)     if isinstance(shape, tf.TensorShape):
    [533](file:///C:/Users/Hideshi_Ooka/AppData/Local/Programs/Python/Python312/Lib/site-packages/keras/src/backend/common/variables.py:533)         # `tf.TensorShape` may contain `Dimension` objects.
    [534](file:///C:/Users/Hideshi_Ooka/AppData/Local/Programs/Python/Python312/Lib/site-packages/keras/src/backend/common/variables.py:534)         # We need to convert the items in it to either int or `None`

ValueError: Cannot convert '2' to a shape.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions