parikh-et-al-and-bilstm-max-pool/modules/Utils.py
def normalize_embeddings(self, embeddings):
        """
        Normalize the embeddings to have norm 1.
        :param embeddings: 2-d numpy array
        :return: normalized embeddings
        """
        # normalize embeddings
        norms = np.linalg.norm(embeddings.numpy(), axis=1).reshape((-1, 1))
        embeddings = torch.from_numpy(embeddings.numpy() / norms)
        return embeddings

        Normalize the embeddings to have norm 1.
        :param embeddings: 2-d numpy array
        :return: normalized embeddings
        
Normalize the embeddings to have norm 1.
Normalize the embeddings to have norm 1 .
def normalize_embeddings(self, embeddings):
        norms = np.linalg.norm(embeddings.numpy(), axis=1).reshape((-1, 1))
        embeddings = torch.from_numpy(embeddings.numpy() / norms)
        return embeddings
def normalize_embeddings ( self , embeddings ) : norms = np . linalg . norm ( embeddings . numpy ( ) , axis = 1 ) . reshape ( ( - 1 , 1 ) ) embeddings = torch . from_numpy ( embeddings . numpy ( ) / norms ) return embeddings
Normalize the embeddings to have norm 1.
Normalize the embeddings to have norm 1 .
"""
        Normalize the embeddings to have norm 1.
        :param embeddings: 2-d numpy array
        :return: normalized embeddings
        """ # normalize embeddings
None
self
embeddings
2-d numpy array
2 - d numpy array