Unimplemented Error when fitting model

Hello!

I wonder if someone has seen error like this before?

Previous cells all ran just fine; In create_model, I defined a few layers (vague as I am not supposed to post code). It can’t even run for 1 epoch.

[code removed - moderator]
##################### Error

Epoch 1/20


UnimplementedError Traceback (most recent call last)
in
3
4 # Train the model and save the training history
----> 5 history = model.fit(train_pad_trunc_seq, np.array(train_labels), epochs=20, validation_data=(val_pad_trunc_seq, val_labels))

/opt/conda/lib/python3.8/site-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.traceback)
—> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb

/opt/conda/lib/python3.8/site-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
56 try:
57 ctx.ensure_initialized()
—> 58 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
59 inputs, attrs, num_outputs)
60 except core._NotOkStatusException as e:

UnimplementedError: Cast string to float is not supported
[[node binary_crossentropy/Cast
(defined at /opt/conda/lib/python3.8/site-packages/keras/losses.py:1797)
]] [Op:__inference_train_function_40562]

Please see this message:
UnimplementedError: Cast string to float is not supported

Remember to convert labels to numeric type before calling model.fit

See this in the notebook markdown:
The labels are originally encoded as strings ('0' representing negative and '4' representing positive). You need to change this so that the labels are integers and 0 is used for representing negative, while 1 should represent positive.

Hi Thanks! I did see that message and went back to check my code- I converted the labels to integers before this cell so I didn’t think that was the issue. Maybe I should convert it to float instead?

My output for the test of parsing is the following. Since there are no quotations I assumed it was not of string.

############
Labels of last 5 examples should look like this:
[1, 1, 1, 1, 1]

Please click my name and message your notebook as an attachment.

Thank you so much! I just did!

The problem lies in parse_data_from_file. When temp is 0, you’ll add string “0” to labels.
Please fix it.

Thank you so much!!! It is running now! :smiley: I really appreciate your help and time!!