brightmart / text_classification

all kinds of text classification models and more with deep learning
MIT License
7.83k stars 2.57k forks source link

Error: pred must not be a Python bool running train_bert_toy_task.py #110

Open MNCTTY opened 5 years ago

MNCTTY commented 5 years ago

Hi,

I try to run this version of Bert (train_bert_toy_task.py) on my pc and an error arises:

pred must not be a Python bool

I tried to solve it, replacing True with tf.constant(True, dtype=tf.bool), but it induced the other error:

TypeError: Using a tf.Tensor as a Python bool is not allowed. Use if t is not None: instead of if t: to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.

I noticed that the error "pred must not be a Python bool" is also in line 31, where we have no explicit True value, but in bert_train_fn we have use_one_hot_embeddings that is the reason of error.

I don't know if it matter, but the very first error were "no module modeling" that is imported in every .py file in this repository. I decided that it was meant bert_modeling, so the bert_modeling.py exists in this repository. But may be I made a mistake? If so what kind of modeling was meant?

Thank you