Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: operands could not be broadcast together with shapes #2

Open
kodakfu opened this issue Nov 11, 2021 · 1 comment
Open

Comments

@kodakfu
Copy link

kodakfu commented Nov 11, 2021

环境

硬件环境:GPU P100 、linux
软件环境一:TF 2.7 、 transformer-keras 0.4.9
软件环境二:TF2.4 ,trainsformer-keras 0.3.1

数据集

  • 大小:训练集2048条,验证集512条
  • 格式:unsup格式

超参:

  • batch_size :[4,32,64,80]均无效
  • epoch:1
  • mode:unsup

现象:

1、数据正常读取,bert能加载,但是在model.fit报错了

debug信息如下
2021-11-10 10:39:52,766 WARNING utils.py 80] Gradients do not exist for variables ['bert/pooler/dense/kernel:0', 'bert/pooler/dense/bias:0'] when minimizing the loss. If you're using model.compile(), did you forget to provide a lossargument?
975/Unknown - 398s 378ms/step - acc: 0.9998 - loss: 0.0051Traceback (most recent call last):
File "run_simcse.py", line 79, in
save_weights_only=False)
File "/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/usr/local/lib/python3.7/dist-packages/keras/utils/generic_utils.py", line 896, in update
self._values[k][0] += v * value_base
ValueError: operands could not be broadcast together with shapes (64,) (27,) (64,)

我尝试方法

更改数据集大小为batch_size的整数倍,无法解决
davidADSP/GDL_code#63

@luozhouyang
Copy link
Owner

bucket_by_sequence_length函数增加 drop_remainder=True试试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants