trainX Y shape is: (4755, 48, 23) (4755, 60, 23) (4755, 5, 1) Hx= 1 Traceback (most recent call last): File ~\anaconda4\envs\tensorflow\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec exec(code, globals, locals) File d:\lstnet_keras-master\train_batch_a391.py:172 model,normalize = startTrainMult_1H(df,name,config) File D:\lstnet_keras-master\lstm\LSTNet_Interface_a391.py:400 in startTrainMult_1H model = trainModel(trainX1, trainX2 , trainY, config) File D:\lstnet_keras-master\lstm\LSTNet_Interface_a391.py:323 in trainModel model = LSTNetAttention(trainX1,trainX2,trainY,config) File D:\lstnet_keras-master\lstm\LSTNet_Interface_a391.py:297 in LSTNetAttention res = add([concat,z]) File ~\anaconda4\envs\tensorflow\lib\site-packages\keras\layers\merge.py:555 in add return Add(**kwargs)(inputs) File ~\anaconda4\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py:75 in symbolic_fn_wrapper return func(*args, **kwargs) File ~\anaconda4\envs\tensorflow\lib\site-packages\keras\engine\base_layer.py:463 in __call__ self.build(unpack_singleton(input_shapes)) File ~\anaconda4\envs\tensorflow\lib\site-packages\keras\layers\merge.py:90 in build output_shape = self._compute_elemwise_op_output_shape(output_shape, File ~\anaconda4\envs\tensorflow\lib\site-packages\keras\layers\merge.py:59 in _compute_elemwise_op_output_shape raise ValueError('Operands could not be broadcast ' ValueError: Operands could not be broadcast together with shapes (23, 32) (5,)
时间: 2023-09-06 14:11:49 浏览: 173
rich-traceback:Python 日志记录模块的信息回溯
这个错误是由于在使用 Keras 进行模型训练时,两个张量的形状无法进行广播运算所导致的。具体来说,在您的代码中,您使用了 Keras 的 Merge 层中的 Add 层,将两个张量进行相加。但是,这两个张量的形状不匹配,无法进行广播运算,所以会导致这个错误。
您需要检查一下您的代码,确定这两个张量的形状是否正确,并且可以进行相加操作。如果您没有修改过这个代码,可能是数据集的问题,您需要检查一下数据集的形状是否正确。
阅读全文