pretrained_vocab.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:UnstableParser 作者: tdozat 项目源码 文件源码
def __call__(self, placeholder=None, moving_params=None):
    """"""

    embeddings = super(PretrainedVocab, self).__call__(placeholder, moving_params=moving_params)
    # (n x b x d') -> (n x b x d)
    with tf.variable_scope(self.name.title()):
      matrix = linalg.linear(embeddings, self.token_embed_size, moving_params=moving_params)
      if moving_params is None:
        with tf.variable_scope('Linear', reuse=True):
          weights = tf.get_variable('Weights')
          tf.losses.add_loss(tf.nn.l2_loss(tf.matmul(tf.transpose(weights), weights) - tf.eye(self.token_embed_size)))
    return matrix
    #return embeddings # changed in saves2/test8

  #=============================================================
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号