{"id":13715479,"url":"https://github.com/kefirski/pytorch_NEG_loss","last_synced_at":"2025-05-07T04:30:47.913Z","repository":{"id":67900251,"uuid":"83875466","full_name":"kefirski/pytorch_NEG_loss","owner":"kefirski","description":"NEG loss implemented in pytorch","archived":false,"fork":false,"pushed_at":"2017-07-07T08:49:15.000Z","size":34,"stargazers_count":125,"open_issues_count":1,"forks_count":26,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-22T07:52:38.979Z","etag":null,"topics":["python","pytorch","word2vec"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kefirski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-03-04T07:32:11.000Z","updated_at":"2024-01-04T16:12:00.000Z","dependencies_parsed_at":"2023-10-21T15:15:16.814Z","dependency_job_id":null,"html_url":"https://github.com/kefirski/pytorch_NEG_loss","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kefirski%2Fpytorch_NEG_loss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kefirski%2Fpytorch_NEG_loss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kefirski%2Fpytorch_NEG_loss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kefirski%2Fpytorch_NEG_loss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kefirski","download_url":"https://codeload.github.com/kefirski/pytorch_NEG_loss/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252813656,"owners_count":21808363,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","pytorch","word2vec"],"created_at":"2024-08-03T00:00:59.455Z","updated_at":"2025-05-07T04:30:47.649Z","avatar_url":"https://github.com/kefirski.png","language":"Python","funding_links":[],"categories":["PyTorch论文推荐"],"sub_categories":[],"readme":"# Pytorch Negative Sampling Loss\n\n[Negative Sampling Loss](https://arxiv.org/abs/1310.4546) implemented in [PyTorch](http://www.pytorch.org).\n\n![NEG Loss Equation](images/neg.png)\n\n## Usage\n\n```python\nneg_loss = NEG_loss(num_classes, embedding_size)\n    \noptimizer = SGD(neg_loss.parameters(), 0.1)\n    \nfor i in range(num_iterations):\n    ''' \n    input is [batch_size] shaped tensors of Long type\n    while target has shape of [batch_size, window_size]\n    '''\n    input, target = next_batch(batch_size)\n        \n    loss = neg_loss(input, target, num_sample)\n    \n    optimizer.zero_grad()\n    loss.backward()\n    optimizer.step()\n    \nword_embeddings = neg_loss.input_embeddings()        \n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkefirski%2Fpytorch_NEG_loss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkefirski%2Fpytorch_NEG_loss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkefirski%2Fpytorch_NEG_loss/lists"}