我正试图使用视觉转换器的拥抱面实现来获得最后一个密集层的特征向量
为了从倒数第二层获取信息,您需要output_hidden_states=True
。在我的上下文中有一个例子:
configBert = BertConfig.from_pretrained('bert-base-uncased', output_hidden_states=True, num_labels=NUM_LABELS)
modelBert = TFBertModel.from_pretrained('bert-base-uncased', config=configBert)