Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Convert torch.nn.Embedding layer to numpy array

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)
Source by discuss.pytorch.org #
 
PREVIOUS NEXT
Tagged: #Convert #layer #numpy #array
ADD COMMENT
Topic
Name
5+8 =