### fill the gap (one line) ### # apply the 'get_word_att_coeffs' model over all the sentences in 'my_review_tensor', and store the results as 'word_coeffs' word_coeffs = TimeDistributed(get_word_att_coeffs)(my_review_tensor) word_coeffs = K.eval( word_coeffs ) # shape = (1, 7, 30, 1): (batch size, nb of sents in doc, nb of words per sent, coeff) word_coeffs = word_coeffs[ 0, :, :, 0] # shape = (7, 30) (coeff for each word in each sentence) word_coeffs = sent_coeffs * word_coeffs # re-weigh according to sentence importance word_coeffs = np.round((word_coeffs * 100).astype(np.float64), 2) word_coeffs_list = word_coeffs.tolist() # match text and coefficients text_word_coeffs = [ list(zip(words, word_coeffs_list[idx][:len(words)])) for idx, words in enumerate(my_review_text) ] for sent in text_word_coeffs: [print(elt) for elt in sent] print('= = = =') # sort words by importance within each sentence text_word_coeffs_sorted = [ sorted(elt, key=operator.itemgetter(1), reverse=True) for elt in text_word_coeffs