📜  将 torch.nn.Embedding 层转换为 numpy 数组 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:37.334000             🧑  作者: Mango

代码示例1
bert_embeddings = bert_model.get_input_embeddings()

# Convert bert embeddings from a torch.nn.Module type to a numpy array
bert_embedding_numpy = np.array(bert_embeddings.weight.data)