I'm building a neural network that is supposed to classify input words in some way. Without going into much detail on the network itself, I was looking for a way to convert my input words to an integer format, in order to use TensorFlow's
import tensorflow as tf
s = tf.string_to_number("TEST", out_type=tf.int32)
sess = tf.InteractiveSession()
StringToNumberOp could not correctly convert string: TEST
Can anyone tell me what I'm missing here?
You are missing the purpose of
string_to_number it is supposed to convert a number, represented as string, to the numerical type, like
tf.string_to_number('1'), it is not "one hot encoder" for strings (how would it be able to figure out the size in the vocab in the first place?)
There is a nice tutorial in tensorflow itself which shows how to train embedding models in word2vec_basic.py which goes through everything, starting with data reading and ending with full embedding using the lookup op.