Skip to main content

orientLoss is a classification loss function @pytorch. It less prone to overfitting compared to crossEntropy. Compatible with random vector/embeddings with direction-indicating categories、probabilistic、oneHot as target.

Project description

orientLoss

orientLoss is a classification loss function. It less prone to overfitting compared to crossEntropy. Compatible with random vector/embeddings with direction-indicating categories、probabilistic、oneHot as target.

思路说明

很多时候网络需要输出的类别数远高于网络中使用的特征数/通道数,需要在最后一层加一个巨大的线性层将输出扩增才送入交叉熵损失.但本质上这一层并没有增加信息量,所以可以使用某些损失函数取代这一过程.再考虑到交叉熵由于其下降没有终点,容易引起过拟合.通过设计公式从形状上逼近和优化维度无限扩增后的交叉熵损失得到了这个损失函数.

Install

pip install orientLoss

Use

from orientLoss import orientLoss
...
loss=orientLoss(input,target,dim=-1,meanOut=True,angleSmooth=1,normSmooth=1,dimScalingOrd=0,eps=1e-8)

target可以是由方向指示类别的随机向量/嵌入、概率、独热编码. 概率或独热编码输入时最好各类别独立进行标准化后再送入损失函数.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orientloss-0.0.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orientloss-0.0.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file orientloss-0.0.1.tar.gz.

File metadata

  • Download URL: orientloss-0.0.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for orientloss-0.0.1.tar.gz
Algorithm Hash digest
SHA256 dc9a9e8afdddcf9fa0e0900a12e1b06f55a892786fc7294b786cbcb11f068188
MD5 8ff4f365230cf418f9dac5f233250029
BLAKE2b-256 16e77d0fd254af7d49e9501c41cfc289a85b52d6ba2b3da90d6d9322a5cb5608

See more details on using hashes here.

Provenance

The following attestation bundles were made for orientloss-0.0.1.tar.gz:

Publisher: python-publish.yml on PsycheHalo/orientLoss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file orientloss-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: orientloss-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for orientloss-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e5b8008163e80435cd3877fdd603aefe8d1863e5425f8e5248b89eb5bbdd777
MD5 99abd5f2a96a4c1fe743aa4907bb9e64
BLAKE2b-256 7a30e6af11f0b8e5ef922673d125ef56e1f862b1debfcff97ac0412994894d4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for orientloss-0.0.1-py3-none-any.whl:

Publisher: python-publish.yml on PsycheHalo/orientLoss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page