Я хочу сделать некоторые операции над входом внутри модели. Например, разбивая входной текст, я попытался использовать K.map_fn и слой Lambda, но получил ошибку
Фиктивная модель 1:
def split_text(text):
return text.split()
# model
input_text_1 = Input(shape=(1,), dtype='string')
context = Lambda(lambda x: K.map_fn(split_text, x))(input_text_1)
model = Model(inputs=[input_text_1], outputs=context)
Ошибка: AttributeError: 'Tensor' object has no attribute 'split'
Я также хочу применить одну и ту же концепцию к нескольким входам, чтобы сделать более сложную операцию над текстом
Макетная модель 2:
def more_complex_text_operation(text1, text2):
# get a vector of all the indices in text2.words that occurs in text1
return one_d_vector_of_ones_zeros
input_text_1 = Input(shape=(1,), dtype='string')
input_text_2 = Input(shape=(1,), dtype='string')
context = Lambda(lambda x: K.map_fn(more_complex_text_operation, x))([input_text_1, input_text_2])
model = Model(inputs=[input_text_1, input_text_2], outputs=context)
Думаю, я не понимаю, как это сделатьиспользуя K.map_fn.
Есть идеи?