Я пытаюсь построить модель, в которой для реализации используется два текстовых ввода и один горячий вектор на основе одного из индексов ввода.
Я создал следующие пользовательские функции:
def get_index(text, word):
# get index
index = get_expression_indices(text, word)
id_seq = []
for i in range(70): #length of the text
if i == index :
id_seq.insert(i, 1)
else:
id_seq.insert(i, 0)
return np.array(id_seq)
def get_index_tensor(input):
return tf.py_function(get_index, [input[0], input[1]], tf.string)
А вот фиктивная модель
# input layers
input_text_1 = Input(shape=(1,), dtype='string')
input_text_2 = Input(shape=(1,), dtype='string')
context = Lambda(emb_utils.get_index_tensor, output_shape=(None,))([input_text_1, input_text_2])
model = Model(inputs=[input_text_1, input_text_2], outputs=context)
Я получаю ошибку: ValueError: Cannot iterate over a shape with unknown rank.
Выходная форма должна быть (batch_size, 70, 1) Когда я удаляю output_sape=(None,)
Я получаю TypeError: object of type 'NoneType' has no len()
Любые идеи о том, в чем может быть проблема?