资源算法pytorch_NEG_loss

pytorch_NEG_loss

2019-09-18 | |  93 |   0 |   0

Pytorch Negative Sampling Loss

Negative Sampling Loss implemented in PyTorch.

NEG Loss Equation

Usage

neg_loss = NEG_loss(num_classes, embedding_size)optimizer = SGD(neg_loss.parameters(), 0.1)for i in range(num_iterations):
    '''     input is [batch_size] shaped tensors of Long type    while target has shape of [batch_size, window_size]    '''
    input, target = next_batch(batch_size)

    loss = neg_loss(input, target, num_sample)

    optimizer.zero_grad()
    loss.backward()
    optimizer.step()word_embeddings = neg_loss.input_embeddings()


上一篇:pytorch-prunes

下一篇:DepthNet

用户评价
全部评价

热门资源

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • shih-styletransfer

    shih-styletransfer Code from Style Transfer ...

  • inferno-boilerplate

    This is a very basic boilerplate example for pe...