grader-required-cell
分级功能:标记化标签
def tokenize_labels(all_labels,split_labels):“”标记标签
Args:
all_labels (list of string): labels to generate the word-index from
split_labels (list of string): labels to tokenize
Returns:
label_seq_np (array of int): tokenized labels
"""
### START CODE HERE
# Instantiate the Tokenizer (no additional arguments needed)
label_tokenizer = Tokenizer()
# Fit the tokenizer on all the labels
label_tokenizer.fit_on_texts(all_labels)
# Convert labels to sequences
label_seq = label_tokenizer.texts_to_sequences(split_labels)
# Convert sequences to a numpy array. Don't forget to substact 1 from every entry in the array!
label_seq_np = np.array(label_seq)-1 <----------- i don't know what is wrong
### END CODE HERE
return label_seq_np
输出为:
TypeError:不支持的操作数类型-:'list'和'int'
1条答案
按热度按时间zlhcx6iw1#
尝试: