Skip to main content

surMSE is a A loss function @PyTorch, that allows the target to be exceeded in the target direction.

Project description

surMSE

A loss function @PyTorch, that allows the target to be exceeded in the target direction.

思路说明

允许输入与目标方向相同,但模长比目标大.此时损失为零. 因为神经网络经常表现出输出稍微不达目标的特性,通过减弱使输出接近零的梯度,尝试缓解这个问题.

Install

pip install surMSE

Use

from surMSE import surMSE
...
loss=surMSE(input,target,dim=None,scale=False,eps=1e-8,meanOut=True,haveBatch=True)

dim表示在哪些维度上计算损失,一般开启除Batch维之外的全部维度.设定为None则自动计算.
dim=None,haveBatch=True时,自动排除首维.dim=None,haveBatch=False时在全部维度上计算.
scale控制是否根据target是模长控制对应样本损失的增益,如果开启,损失的值和梯度将于target的模长正相关.
loss=loss/(target.norm().square()+eps)
meanOut控制是否在返回前使用平均的方法合并"dim"参数指定外的剩余维度.如果不开启,取决于数据维度和dim设置,返回的tensor将不一定只有一个元素.

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

surmse-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.

surmse-0.0.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: surmse-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.13.12

File hashes

Hashes for surmse-0.0.1.tar.gz
Algorithm Hash digest
SHA256 954a3fccface7efacf7976b2bdca693ba958100463bd2a1eede1e19427854170
MD5 43c9a7562d35cb4222603eeef08a6d93
BLAKE2b-256 eeb8a4d816e4640e67529b249b147a1cde328fe3f55f56478461c1e3fb1fca69

See more details on using hashes here.

Provenance

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

Publisher: python-publish.yml on PsycheHalo/surMSE

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

File details

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

File metadata

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

File hashes

Hashes for surmse-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9be5fcf966a94a782beb2333412766fc43c5daaa6862fa3a43fccb89451d583a
MD5 c15ec3d534dd798a731c491cb1f35f65
BLAKE2b-256 2ce47e396962eab5516689b90fd628f07c84c9a33e3a854dd0c2566e285e08a1

See more details on using hashes here.

Provenance

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

Publisher: python-publish.yml on PsycheHalo/surMSE

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