Hi, I'm trying to use the code you post in the previous issue and it seems that there is an shape error in def attention_pooling
Traceback (most recent call last):
File "", line 1, in
runfile('/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py', wdir='/home/yli/Documents/CID_CNN_ATTENTION')
File "/home/yli/tensorflow/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "/home/yli/tensorflow/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py", line 746, in
processing(trainfile, testfile,train_feature_file, test_feature_file)
File "/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py", line 723, in processing
model = RExtractionModel(max_lengths=sum(max_lengths),index = train_split, embedding_weights=embedding_weights, vocabulary=vocabulary, manual_length = manual_length, bag_size = bag_size)
File "/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py", line 377, in init
self.h_pool_attention.append(self.attention_pooling(x = pool , attention_dim = attention_dim, num_filters = num_filters))
File "/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py", line 433, in attention_pooling
return tf.matmul(x,A)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 2455, in matmul
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 5333, in mat_mul
name=name)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
op_def=op_def)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1823, in init
control_input_ops)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1662, in _create_c_op
raise ValueError(str(e))
ValueError: Shape must be rank 2 but is rank 4 for 'pooling-attention-0/MatMul_1' (op: 'MatMul') with input shapes: [?,1,1,300], [?,100].
I will appreciate if you can help me to figure it out
Hi, I'm trying to use the code you post in the previous issue and it seems that there is an shape error in def attention_pooling Traceback (most recent call last):
File "", line 1, in
runfile('/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py', wdir='/home/yli/Documents/CID_CNN_ATTENTION')
File "/home/yli/tensorflow/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile execfile(filename, namespace)
File "/home/yli/tensorflow/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py", line 746, in
processing(trainfile, testfile,train_feature_file, test_feature_file)
File "/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py", line 723, in processing model = RExtractionModel(max_lengths=sum(max_lengths),index = train_split, embedding_weights=embedding_weights, vocabulary=vocabulary, manual_length = manual_length, bag_size = bag_size)
File "/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py", line 377, in init self.h_pool_attention.append(self.attention_pooling(x = pool , attention_dim = attention_dim, num_filters = num_filters))
File "/home/yli/Documents/CID_CNN_ATTENTION/distance_pos_fea_cnn_rnn_v1.py", line 433, in attention_pooling return tf.matmul(x,A)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 2455, in matmul a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 5333, in mat_mul name=name)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op op_def=op_def)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1823, in init control_input_ops)
File "/home/yli/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1662, in _create_c_op raise ValueError(str(e))
ValueError: Shape must be rank 2 but is rank 4 for 'pooling-attention-0/MatMul_1' (op: 'MatMul') with input shapes: [?,1,1,300], [?,100].
I will appreciate if you can help me to figure it out