twopin / CAMP

predicting peptide-protein interactions
117 stars 30 forks source link

Self_Attention passes Reshape3.0 to Theano, which requires a 1-D or 2-D input #6

Closed tsznxx closed 2 years ago

tsznxx commented 2 years ago

Anyone can help with this? Thank you!

x must be 1-d or 2-d tensor of floats. Got TensorType(float32, 3D)

Software versions: Python 2.7.18 |Anaconda, Inc.| (default, Jun 4 2021, 14:47:46) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information.

print (keras.version,tensorflow.version,rdkit.version,sklearn.version) ('2.0.8', '1.2.1', '2018.09.3', '0.20.3')

$ python -u predict_CAMP.py Using Theano backend. 2021-09-29 14:25:44.007318: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 2021-09-29 14:25:44.007379: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2021-09-29 14:25:44.007404: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2021-09-29 14:25:44.007429: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2021-09-29 14:25:44.007452: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. ('Start loading model :', './model/CAMP.h5') Traceback (most recent call last): File "predict_CAMP.py", line 175, in model = load_model(model_name,custom_objects={'Self_Attention': Self_Attention}) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/keras/models.py", line 239, in load_model model = model_from_config(model_config, custom_objects=custom_objects) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/keras/models.py", line 313, in model_from_config return layer_module.deserialize(config, custom_objects=custom_objects) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/keras/layers/init.py", line 54, in deserialize printable_module_name='layer') File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/keras/utils/generic_utils.py", line 139, in deserialize_keras_object list(custom_objects.items()))) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/keras/engine/topology.py", line 2497, in from_config process_node(layer, node_data) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/keras/engine/topology.py", line 2454, in process_node layer(input_tensors[0], kwargs) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/keras/engine/topology.py", line 602, in call output = self.call(inputs, kwargs) File "/home/data/TData/software/Denodo_CAMP/twopin-CAMP-0708396/Self_Attention.py", line 29, in call QK = K.softmax(QK) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 1529, in softmax return T.nnet.softmax(x) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/theano/tensor/nnet/nnet.py", line 815, in softmax return softmax_op(c) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/theano/gof/op.py", line 615, in call node = self.make_node(*inputs, **kwargs) File "/home/data/anaconda3/envs/CAMPNoGPU/lib/python2.7/site-packages/theano/tensor/nnet/nnet.py", line 430, in make_node x.type) ValueError: x must be 1-d or 2-d tensor of floats. Got TensorType(float32, 3D)

twopin commented 2 years ago

Our codes are implemented in Keras (tensorflow backend). I notice that the error message indicates that the codes are currently running in Theano backend on your computer. You need to switch the backend to keras(tensorflow) by specifying that.