FreedomIntelligence / qnn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: Dimensions must be equal, but are 50 and 42 for 'complex_mixture_1/mul' (op: 'Mul') with input shapes: [?,42,1,50,42,1,50], [?,42,1,50,50].

ymz1124 opened this issue · comments

王本友您好,运行代码时报错:维度不匹配。是否是输入的数据不对?如果是输入数据不对,是否可以更新一份能跑的数据?其它输出信息如下:

Dictionary size = 16948
Getting word embedding:
Loading word embedding from text file.
glove/glove.6B.50d.txt
100000 words have been loaded.
200000 words have been loaded.
300000 words have been loaded.
400000 words have been loaded.
The dimensionality of embedding is 50
15674 words in the dataset are found in embedding
15675 words are in embedding
1273 words are not in embedding
Done.

commented

could you please provide more details?

Thanks. These is information from console log:
`Done.
Getting dictionary:
Done.
Dictionary size = 16948
Getting word embedding:
Loading word embedding from text file.
glove/glove.6B.50d.txt
100000 words have been loaded.
200000 words have been loaded.
300000 words have been loaded.
400000 words have been loaded.
The dimensionality of embedding is 50
15674 words in the dataset are found in embedding
15675 words are in embedding
1273 words are not in embedding
Done.
matching network type: Siamese Network with local_mixture
representation network type: local_mixture
WARNING:tensorflow:From F:\Python36\lib\site-packages\tensorflow_core\python\ops\resource_variable_ops.py:1630: calling BaseResourceVariable.init (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.
Instructions for updating:
If using Keras pass *_constraint arguments to layers.
Traceback (most recent call last):
File "F:\Python36\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1607, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 50 and 42 for 'complex_mixture_1/mul' (op: 'Mul') with input shapes: [?,42,1,50,42,1,50], [?,42,1,50,50].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "F:/python-for-paper/quantumComputation/qnn-master/run_cnm.py", line 123, in
performance = run(params, reader)
File "F:/python-for-paper/quantumComputation/qnn-master/run_cnm.py", line 23, in run
qdnn = models.setup(params)
File "F:\python-for-paper\quantumComputation\qnn-master\models\match_init_.py", line 10, in setup
model = SiameseNetwork(opt)
File "F:\python-for-paper\quantumComputation\qnn-master\models\match\SiameseNetwork.py", line 44, in init
self.representation_model = representation_model_factory.setup(opt)
File "F:\python-for-paper\quantumComputation\qnn-master\models\representation_init_.py", line 16, in setup
model = LocalMixtureNN(opt)
File "F:\python-for-paper\quantumComputation\qnn-master\models\representation\LocalMixtureNN.py", line 36, in init
super(LocalMixtureNN, self).init(opt)
File "F:\python-for-paper\quantumComputation\qnn-master\models\BasicModel.py", line 7, in init
self.model = self.build()
File "F:\python-for-paper\quantumComputation\qnn-master\models\representation\LocalMixtureNN.py", line 40, in build
self.probs = self.get_representation(self.doc)
File "F:\python-for-paper\quantumComputation\qnn-master\models\representation\LocalMixtureNN.py", line 86, in get_representation
[sentence_embedding_real, sentence_embedding_imag]= ComplexMixture()([seq_embedding_real, seq_embedding_imag, self.weight])
File "F:\Python36\lib\site-packages\keras\engine\base_layer.py", line 489, in call
output = self.call(inputs, **kwargs)
File "F:\python-for-paper\quantumComputation\qnn-master\layers\cvnn\mixture.py", line 81, in call
output_real = output_real*weight #shape: (None, 300, 300)
File "F:\Python36\lib\site-packages\tensorflow_core\python\ops\math_ops.py", line 899, in binary_op_wrapper
return func(x, y, name=name)
File "F:\Python36\lib\site-packages\tensorflow_core\python\ops\math_ops.py", line 1206, in _mul_dispatch
return gen_math_ops.mul(x, y, name=name)
File "F:\Python36\lib\site-packages\tensorflow_core\python\ops\gen_math_ops.py", line 6701, in mul
"Mul", x=x, y=y, name=name)
File "F:\Python36\lib\site-packages\tensorflow_core\python\framework\op_def_library.py", line 794, in _apply_op_helper
op_def=op_def)
File "F:\Python36\lib\site-packages\tensorflow_core\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "F:\Python36\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3357, in create_op
attrs, op_def, compute_device)
File "F:\Python36\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3426, in _create_op_internal
op_def=op_def)
File "F:\Python36\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1770, in init
control_input_ops)
File "F:\Python36\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1610, in _create_c_op
raise ValueError(str(e))
ValueError: Dimensions must be equal, but are 50 and 42 for 'complex_mixture_1/mul' (op: 'Mul') with input shapes: [?,42,1,50,42,1,50], [?,42,1,50,50].`

Thanks to Quichi Li and wabyking:
pip uninstall keras
pip install keras==2.2.4