BrikerMan / Kashgari

Kashgari is a production-level NLP Transfer learning framework built on top of tf.keras for text-labeling and text-classification, includes Word2Vec, BERT, and GPT2 Language Embedding.
http://kashgari.readthedocs.io/
Apache License 2.0
2.4k stars 441 forks source link

[Question] 如何输出predict的中间层value #457

Closed james-robinhood closed 2 years ago

james-robinhood commented 3 years ago

You must follow the issue template and provide as much information as possible. otherwise, this issue will be closed. 请按照 issue 模板要求填写信息。如果没有按照 issue 模板填写,将会忽略并关闭这个 issue

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

You can post pictures, but if specific text or code is required to reproduce the issue, please provide the text in a plain text format for easy copy/paste.

Environment

[Paste requirements.txt file here]

Question

[A clear and concise description of what you want to know.] 我已经搭建了一个用了bert embedding的的 cnn_model做classification。请问在我predict的时候如何可以输出 embedding之后的conv1d (Conv1D) 层的结果呢?这里不是指weight,而是直接在predict的过程中的每个node的值

BrikerMan commented 3 years ago
  1. 先按照正常流程构建 kashgari 模型,训练
  2. kashgari 模型的 tf_model 属性就是对应的 tf 模型,使用这个模型的输入作为输入,目标输出层作为输出构建一个模型。
  3. 使用预处理模块把文本转换为向量,然后输入到新构建的模型。
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.