title: Tensorflow with string based tabular data [UNIMPLEMENTED: Cast string to float is not supported]
body: <p>I am having the following tabular data stored in a dataframe <code>df</code>:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">input3</th>
  <th style="text-align: left;">input2</th>
  <th style="text-align: left;">score</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">aaaaaa</td>
  <td style="text-align: left;">xxxxxx</td>
  <td style="text-align: left;">0.1.</td>
  </tr>
  <tr>
  <td style="text-align: left;">...</td>
  <td style="text-align: left;">...</td>
  <td style="text-align: left;">...</td>
  </tr>
  <tr>
  <td style="text-align: left;">bbbbbb</td>
  <td style="text-align: left;">yyyyyy</td>
  <td style="text-align: left;">0.1.</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to build a regression model on that using TF functional API. Because of the strings, I am using Embedding layers. Here is the network:</p>
  <pre><code>input1 = Input(shape=(1,), name=&quot;input1&quot;)
  embedding1 = Embedding(n_input1, 5)(input1)
  vec1 = Flatten()(embedding1)
  
  # creating user embedding path
  input2 = Input(shape=(1,), name=&quot;input2&quot;)
  embedding2 = Embedding(n_input2, 5)(input2)
  vec2 = Flatten()(embedding2)
  
  # concatenate features
  conc = Concatenate()([vec1, vec2])
  
  # add fully-connected-layers
  fc1 = Dense(256, activation='relu')(conc)
  fc2 = Dense(128, activation='relu')(fc1)
  fc3 = Dense(128, activation='relu')(fc2)
  out = Dense(1)(fc3)
  
  # Create model and compile it
  model = Model([input1, input2], out)
  model.compile('adam', 'mean_squared_error')
  </code></pre>
  <p>where <code>n_input_1</code> and <code>n_input_2</code> are the number of unique items in each columns.</p>
  <p>Because, I have <code>df.dtypes</code> returning:</p>
  <pre><code>input1          object
  input2          object
  score          float64
  dtype: object
  </code></pre>
  <p>I do <code>df = data_df.astype({'input1': 'string', 'input2': 'string'})</code> -- not sure this is useful</p>
  <p>When trying to fit the model using:
  <code>history = model.fit([df.input1, df.input2], df.score, epochs=10, verbose=1)</code></p>
  <p>I end up with the following error:</p>
  <pre><code>UnimplementedError: Graph execution error:
  
  Detected at node 'model/Cast' defined at (most recent call last):
  ...
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/engine/functional.py&quot;, line 671, in _conform_to_reference_input
        tensor = tf.cast(tensor, dtype=ref_input.dtype)
  Node: 'model/Cast'
  2 root error(s) found.
    (0) UNIMPLEMENTED:  Cast string to float is not supported
       [[{{node model/Cast}}]]
    (1) CANCELLED:  Function was cancelled before it was started
  0 successful operations.
  0 derived errors ignored. [Op:__inference_train_function_965]
  </code></pre>
  <p>Not really sure what I missed here ?</p>