Skip to main content

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,protect=None)

dim表示在哪些维度上计算损失,一般开启除Batch维之外的全部维度.设定为None则自动计算.
dim=None,haveBatch=True时,自动排除首维.dim=None,haveBatch=False时在全部维度上计算.
scale控制是否根据target模长控制对应样本损失的增益,如果开启,将通过target模长给损失加权;如果关闭,在一半空间上将等效于MSE.
meanOut控制是否在返回前使用平均的方法合并"dim"参数指定外的剩余维度.如果不开启,取决于数据维度和dim设置,返回的tensor将不一定只有一个元素.
protect柔性防止损失值超越protect值的样本对总损失造成过大影响.设置为0关闭此功能,设置为None自动设置当前批次损失值的平均值作为protect值.

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.3.tar.gz (8.1 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.3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: surmse-0.0.3.tar.gz
  • Upload date:
  • Size: 8.1 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.3.tar.gz
Algorithm Hash digest
SHA256 9d6c5d41a116604c03a33e954fe85b727da0bd13ba73c096cc8fc01a27658d37
MD5 674473760a2b2f71c8533186ae2eb111
BLAKE2b-256 d4c886436fefd470c8f0b807e3074effbd72e57936319953e5fd601d6a8024d9

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for surmse-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 40452471f203c989c5e09a7cf3fa83dacf94547dc02e34600db6d19e9469cca2
MD5 fa57abb5c75d3af8d5f73397361b423b
BLAKE2b-256 967a70cc258329735bd6bac3a59a8c3edfa9441bb23eedabb0c39a4c09e253b3

See more details on using hashes here.

Provenance

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

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page