Data Science, Machine Learning, NLP, Transformers, Word Embeddings.
len(hidden_states[0][0])) print ("Number of hidden units:", len(hidden_states[0][0][0])) # Concatenate the tensors for all layers. token_embeddings = torch.stack(hidden_states, dim=0) # Swap dimensions, so we get tensors in format: [sentence, tokens, hidden layes, features] token_embeddings =