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

思路说明

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

Install

pip install surMSE

Use

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

dim表示在哪些维度上计算损失,一般开启除Batch维之外的全部维度.设定为None则自动计算.
dim=None,haveBatch=True时,自动排除首维.dim=None,haveBatch=False时在全部维度上计算.
scale控制是否根据target模长控制对应样本损失的增益,如果开启,将通过target模长给损失加权;如果关闭,在一半空间上将等效于MSE.
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.2.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.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: surmse-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 2741c5b5b4af2fa18e473c1c394f9403fe41a5543f54011e4057d20a64e1e507
MD5 03c36f94a223309ce9cccb0005b522fb
BLAKE2b-256 efb7422d01cb4b7bdbfcfd13808461fb65cae1bb337b2d351f3d0030c91a3b94

See more details on using hashes here.

Provenance

The following attestation bundles were made for surmse-0.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: surmse-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bced3e14fdf33709b1afb0ad31b0cfb2e941ad857a2323616bf88e3df2330188
MD5 21766a6121e401cf33f8163256a63708
BLAKE2b-256 47cffa39b958c0bb9625500ad4a9c5daaf56357e2ed7967cb2aa847dc0a6dd25

See more details on using hashes here.

Provenance

The following attestation bundles were made for surmse-0.0.2-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