bert icon indicating copy to clipboard operation
bert copied to clipboard

Seems the pre-trained Bert-base Chinese model only support binary classification?

Open mmpang opened this issue 8 years ago • 5 comments

I do the fine-tuning with the pre-trained bert-base chinese model, chinese_L-12_H-768_A-12 to be specific.But I cannot do multiclass classification(28 classes). Actually, it reports as follows: InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [28] rhs shape= [2] [[Node: save/Assign_598 = Assign[T=DT_FLOAT, _class=["loc:@output_bias/adam_m"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](output_bias/adam_m, save/RestoreV2/_1201)]] [[Node: save/Identity_1/_1197 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_1201_save/Identity_1", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

Can anyone help?

mmpang avatar Nov 15 '18 07:11 mmpang

Does your binary classification work successfully?

monanahe avatar Nov 15 '18 08:11 monanahe

Are you pointing to an old checkpoint directory that is loading a checkpoint from a previous run? It seems to be trying to load a 2-class checkpoint.

jacobdevlin-google avatar Nov 15 '18 16:11 jacobdevlin-google

Does your binary classification work successfully?

Yes it does.

mmpang avatar Nov 17 '18 06:11 mmpang

Are you pointing to an old checkpoint directory that is loading a checkpoint from a previous run? It seems to be trying to load a 2-class checkpoint.

I don't thik so, cause I downloaded the model from https://github.com/google-research/bert. MD5: 677977a2f51e09f740b911866423eaa5 bert_config.json bd144ebf7bb0d32adf7ada7c13c21f7c bert_model.ckpt.data-00000-of-00001 3c7ec74cb0430ccf80c6cb123732615e bert_model.ckpt.index 1cb8808035884f7ce416fc9eb59cd40e bert_model.ckpt.meta 3b5b76c4aef48ecf8cb3abaafe960f09 vocab.txt

mmpang avatar Nov 17 '18 06:11 mmpang

There is a tensor called cls/seq_relationship/output_bias (DT_FLOAT) [2] in the checkpoint but that shouldn't cause an issue. Did you modify the actual model construction code? It seems like its either a scoping issue or you've added two new variables with the same name.

jacobdevlin-google avatar Nov 17 '18 18:11 jacobdevlin-google