Я проверил несколько вопросов в Stakoverflow и руководствах по встраиванию Keras и TensorFlow, но не нашел ответа, который мне подходит. Я объясняю.
У меня есть словарь 200.000 слов. С 10376 уникальных «слов». Они представляют идентификатор сотового устройства. IMEI. В данном конкретном случае я хочу обработать их с помощью Keras Functional API, а затем объединить с числовыми данными, когда решу эту проблему.
Но я могу пройти первый уровень, к какой части относится встраивание.
Здесь код
#example of device
0 jg4M/taYRc2cBJPGa8c8vw==
1 jg4M/taYRc2cBJPGa8c8vw==
2 jg4M/taYRc2cBJPGa8c8vw==
3 chIM3a44QxatbmmjyBFGDQ==
4 PdhyfpkIT8Weslb54thwuQ==
5 lrDcRnK7RtKkvaqaYjliBQ==
#lenght of the device
device_len = len(device)
device_len
200000
#uniques device inside the 200000
top_words = len(np.unique(device))
top_words
10376
#keras encoded
encoded_docs = [one_hot(d, top_words) for d in device]
#max length of the vector for each word
max_length = 2
padded_docs = pad_sequences(encoded_docs, maxlen=max_length, padding='post')
print(padded_doc)
[[10269 9475]
[10269 9475]
[10269 9475]
...
[ 1340 2630]
[ 7270 0]
[ 2364 9298]]
#converted to tensors
padded_docs = tf.convert_to_tensor(padded_docs)
sess = tf.InteractiveSession()
print(padded_docs.eval())
sess.close()
#here is the networks
top_words = 10376
embedding_vector_length = 2
x = Embedding(top_words, embedding_vector_length)(padded_docs)
x = Dense(2, activation='sigmoid')(x)
modelx = Model(inputs=padded_docs, outputs = x)
ValueError: Input tensors to a Model must come from `keras.layers.Input`. Received: Tensor("Const:0", shape=(200000, 2), dtype=int32) (missing previous layer metadata).
Я проверяю похожие вопросы и ответы, но не могу найти что-то, что мне подходит.
Если кто-то может мне помочь, будет оченьоценил
Большое спасибо.