Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yiming-wange
GitHub Repository: yiming-wange/cs224n-2023-solution
Path: blob/main/a4/__pycache__/model_embeddings.cpython-310.pyc
1003 views
o

}�!d�@s&dZddlmZGdd�dej�ZdS)z�
CS224N 2022-23: Homework 4
model_embeddings.py: Embeddings for the NMT model
Pencheng Yin <[email protected]>
Sahil Chopra <[email protected]>
Anand Dhoot <[email protected]>
Vera Lin <[email protected]>
Siyan Li <[email protected]>
�Ncs eZdZdZ�fdd�Z�ZS)�ModelEmbeddingsz>
    Class that converts input words to their embeddings.
    csdtt|���||_d|_d|_|jd}|jd}t�	t
|j�||�|_t�	t
|j�||�|_dS)z�
        Init the Embedding layers.

        @param embed_size (int): Embedding size (dimensionality)
        @param vocab (Vocab): Vocabulary object containing src and tgt languages
                              See vocab.py for documentation.
        Nz<pad>)�superr�__init__�
embed_size�source�target�src�tgt�nn�	Embedding�len)�selfr�vocabZsrc_pad_token_idxZtgt_pad_token_idx��	__class__��B/Users/yimingwang/Desktop/cs224n/assignment/a4/model_embeddings.pyrs

zModelEmbeddings.__init__)�__name__�
__module__�__qualname__�__doc__r�
__classcell__rrrrrsr)r�torch.nnr
�Modulerrrrr�<module>s