Saturday, April 27, 2019

Sequences and translations to vectors

Vectors are very useful representations of entities in terms of limited chosen dimension. Sequences are formed from different elements but each sequence can be described by a vector.  The choice of dimensions is helpful to imbue the vectors with some latent significance. When the sequences are uniformly mapped to vectors, they become easy to cluster.

Clusters help in finding ground of sequences. They represent the salient topics within the possible groups. This makes it efficient to determine hidden content with in sequences.

Vectors lend meaning not just by their dimensions but also by the weights matrix associated with them. A softmax classifier helps assign these weights.

Sequence to vectors can use a CBOW architecture that predicts a sequence based on the surrounding sequences and the skip gram that predicts the surrounding sequences based on the current sequence as long as sequences are treated as units that occur in tact together in a collection. This is done in a specific way called the softmax function and it is summarized in a formulation as:
p(wo/wi) = exp(vo dash transpose. vi) / sum of such expectations for i,j ranging over the entire sequence database where vw and vw' are input and output vector representations of sequence w in database W. This is a heavily optimized expression but the idea is that each sequence tries to predict every sequence around it. This results in what is called sequence embedding.


#codingexercise

Node GetSuccessor(Node root)
{
if (root == NULL) return root;
if (root.right)
{
Node current = root.right;
While(current && current.left)
       Current = current.left;
Return current;
}
Node parent = root. parent;
While (parent && parent.right == root)
{
   root = parent;
   parent = parent.parent;
}
return parent;
}

No comments:

Post a Comment