Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14331

BERT Model for reviews throwing an error. How do I fix it?

$
0
0

This is the link to the tutorial.This is the code specifically (I just opened in Colab and ran it - so I did not edit anything):

I am getting the following error:

AttributeError: in user code:    File "/usr/local/lib/python3.10/dist-packages/keras/engine/training.py", line 1284, in train_function  *        return step_function(self, iterator)    File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_tf_utils.py", line 1483, in compute_loss  *        return super().compute_loss(*args, **kwargs)    File "/usr/local/lib/python3.10/dist-packages/keras/engine/training.py", line 1109, in compute_loss  **        return self.compiled_loss(    File "/usr/local/lib/python3.10/dist-packages/keras/engine/compile_utils.py", line 263, in __call__        y_t, y_p, sw = match_dtype_and_rank(y_t, y_p, sw)    File "/usr/local/lib/python3.10/dist-packages/keras/engine/compile_utils.py", line 840, in match_dtype_and_rank        if (y_t.dtype.is_floating and y_p.dtype.is_floating) or (    AttributeError: 'NoneType' object has no attribute 'dtype'

after this section of code:

optimizer = tf.keras.optimizers.Adam(learning_rate=5e-5, epsilon=1e-08)model.compile(optimizer=optimizer, loss=model.compute_loss, metrics=['accuracy'])model.fit(train_dataset.shuffle(100).batch(16),          epochs=2,          batch_size=16,          validation_data=val_dataset.shuffle(100).batch(16))

Viewing all articles
Browse latest Browse all 14331

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>