I get the error 2020-01-29 12:49:54.219205: W tensorflow/core/framework/op_kernel.cc:1632] OP_REQUIRES failed at cast_op.cc:123 : Unimplemented: Cast string to float is not supported 2020-01-29 12:49:54.219705: E tensorflow/core/common_runtime/executor.cc:
I have considered converting the strings to integers simply their place in the alffbhet will this work, or is there a better way of having string inputs in keras? Here is my code
import tensorflow as tf
model = tf.keras.models.Sequential()
word = [['ja'],['ske'],['no'],['fork']]
language = [['dansk'],['dansk'],['engelsk'],['engelsk']]
tf.keras.layers.Flatten()
model.add(tf.keras.layers.Dense(128, activation = tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation = tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation = tf.nn.relu))
model.add(tf.keras.layers.Dense(2, activation = tf.nn.softmax))
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy', #mean_absolute_percentage_error
metrics=['accuracy'])
model.fit(word,language, epochs = 100)
Unfortunately, you can't. The machine learning models don't understand words, they understand digits. It is mathematics basically, everything has to be transformed into digits for calculation.
You have to convert your model inputs into meaningful numerics. This can be done using techniques like one Hot encoding etc.