【问题标题】:How to get the output of the last but one layer of the Vision transformer using the hugging face implementation?如何使用拥抱脸实现获得视觉转换器的最后一层的输出?
【发布时间】:2021-09-04 14:13:43
【问题描述】:

我正在尝试使用视觉转换器的拥抱脸实现来获取最后一个密集层的特征向量

【问题讨论】:

  • 您可能想在帖子中添加更多细节!

标签: huggingface-transformers transformer


【解决方案1】:

为了从倒数第二层获取信息,您需要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)

【讨论】:

    猜你喜欢
    • 2021-04-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2020-05-30
    • 2021-03-30
    • 2020-11-26
    • 2020-11-06
    • 2020-09-01
    相关资源
    最近更新 更多