(embed_dic, vocab_dic)
return embedding_matrix
Construct embedding matrix
    
    Args:
        embed_dic : word-embedding dictionary
        vocab_dic : word-index dictionary
    Returns:
        embedding_matrix: return embedding matrix
Construct embedding matrix
    
    Args:
        embed_dic : word-embedding dictionary
        vocab_dic : word-index dictionary
    Returns:
        embedding_matrix: return embedding matrix
Construct embedding matrix Args : embed_dic : word - embedding dictionary vocab_dic : word - index dictionary Returns : embedding_matrix : return embedding matrix
def mkEmbedMatrix(embed_dic, vocab_dic):
    """
    Construct embedding matrix
    
    Args:
        embed_dic : word-embedding dictionary
        vocab_dic : word-index dictionary
    Returns:
        embedding_matrix: return embedding matrix
    """
    if type(embed_dic) is not dict or type(vocab_dic) is not dict:
        raise TypeError('Inputs are not dictionary')
    if len(embed_dic) < 1 or len(vocab_dic) <1:
        raise ValueError('Input dimension less than 1')
    
    EMBEDDING_DIM = len(embed_dic.items()[0][1])
    embedding_matrix = np.zeros((len(vocab_dic) + 1, EMBEDDING_DIM), dtype=np.float32)
    for word, i in vocab_dic.items():
        embedding_vector = embed_dic.get(word)
        if embedding_vector is not None:
            # words not found in embedding index will be all-zeros.
            embedding_matrix[i] = embedding_vector
    return embedding_matrix
def mkEmbedMatrix ( embed_dic , vocab_dic ) : if type ( embed_dic ) is not dict or type ( vocab_dic ) is not dict : raise TypeError ( 'Inputs are not dictionary' ) if len ( embed_dic ) < 1 or len ( vocab_dic ) < 1 : raise ValueError ( 'Input dimension less than 1' ) EMBEDDING_DIM = len ( embed_dic . items ( ) [ 0 ] [ 1 ] ) embedding_matrix = np . zeros ( ( len ( vocab_dic ) + 1 , EMBEDDING_DIM ) , dtype = np . float32 ) for word , i in vocab_dic . items ( ) : embedding_vector = embed_dic . get ( word ) if embedding_vector is not None : # words not found in embedding index will be all-zeros. embedding_matrix [ i ] = embedding_vector return embedding_matrix