Error "Function was cancelled before it was started" in keras and tensorflow

Viewed 476

I'm trying to create a model for predicting whether there should be a space after a particular string. This Google Colab file contains my code without the preprocessing required with very small sample data that matches the format in which the data that's is going to be used for training is.

https://colab.research.google.com/drive/1qBUdAo2FTG8gLwlXjo1Ba7an3mBvCJF_?usp=sharing

One in the "labels" indicates that there should be a space after the corresponding string and zero that there shouldn't be.

The full error is:

 UnimplementedError: 2 root error(s) found.
 (0) Unimplemented:  Cast string to float is not supported
 [[node sequential_5/Cast (defined at <ipython-input-34-23cc1e9dc370>:11) ]]
 (1) Cancelled:  Function was canceled before it was started
 0 successful operations.
 0 derived errors ignored. [Op:__inference_train_function_14019]

Thank you in advance for your solutions.

1 Answers

Base on your model - you should have integer tensor as an input (your first layer is Embedding layer, which expects integer values).

As far as I inderstand - you have a list of all possible input strings in a vocabulory. If so - you have to send integer codes of input string (not a string itself). In your case:

vocab = [0, 1, 2, 3, 4, 5, 6]

where every code is an index in your vocabulory.

It doesn't make sense to use LSTM for this purpose though.

Related