yanfeiguan / reactivity_predictions_substitution

Platforms to predict reactivity for substitution reactions.
17 stars 8 forks source link

Errors encountered while training the model #1

Closed catalystforyou closed 3 years ago

catalystforyou commented 4 years ago

When I try to training the model with the sample data, an error occurred:

ValueError: in user code:

    /home/lhlai_pkuhpc/lustre1/wangsw/software/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py:806 train_function  *
        return step_function(self, iterator)
    /lustre1/lhlai_pkuhpc/ljr/MLQM/ml_QM_GNN/WLN/models.py:64 call  *
        res_atom_hidden = self.reactants_WLN(res_inputs)
    /lustre1/lhlai_pkuhpc/ljr/MLQM/ml_QM_GNN/WLN/layers.py:52 call  *
        h_nei_atom = self.nei_atom(fatom_nei) #(batch, #atoms, max_nb, hidden)
    /home/lhlai_pkuhpc/lustre1/wangsw/software/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py:976 __call__  **
        self.name)
    /home/lhlai_pkuhpc/lustre1/wangsw/software/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/input_spec.py:168 assert_input_compatibility
        layer_name + ' is incompatible with the layer: '

    ValueError: Input 0 of layer dense_1 is incompatible with the layer: its rank is undefined, but the layer requires a defined rank.

Therefore, I tried to fix this error by reshaping fatom_nei and fbond_nei in layers.py:

fatom_nei = tf.reshape(fatom_nei, (4, 10, 10, -1))

fbond_nei = tf.reshape(fbond_nei, (4, 10, 10, -1))

In this way, the former error was fixed, but another error appeared:

tensorflow.python.framework.errors_impl.InvalidArgumentError:  Incompatible shapes: [4] vs. [22]
     [[node gradient_tape/wln_loss/mul/Mul (defined at reactivity.py:178) ]] [Op:__inference_train_function_4257]

Errors may have originated from an input operation.
Input Source operations connected to node gradient_tape/wln_loss/mul/Mul:
 wln_loss/Cast (defined at reactivity.py:105)

Function call stack:
train_function

2020-09-18 16:58:26.206245: W tensorflow/core/kernels/data/generator_dataset_op.cc:103] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated.
     [[{{node PyFunc}}]]

I cannot figure out why these errors happened, so here I'm seeking for your reply and advice. P.S. The predicting function operates well.

yanfeiguan commented 4 years ago

Hi, thanks for pointing out the issue. I made some major changes to the code recently. Please pull the master branch. If it is still raising errors, it would be great to leave more details about how you used the code, e.g., the command and data format. Then I can help you figure out the problem. Thanks!