Skip to main content

A simple implementation of control variates operator (CVor)

Project description

CVor

CVor is a Python package designed for advanced loss computation in neural networks, particularly with PyTorch. It offers a unique approach to calculating loss using three different methods: AO, NN, and LOO. CVor provides low-variance, unbiased gradient estimation based on control variates. It uniquely focuses on transforming the gradient mapping process and demonstrating superior performance in various machine learning benchmarks, including variational autoencoder training and reinforcement learning tasks.

Features

  • Multiple Loss Computation Methods: 'AO' (Average Optimization), 'NN' (Neural Network based), and 'LOO' (Leave-One-Out) methods.
  • Flexible Alpha Parameter: Allows setting the alpha parameter within the range [0, 1] for CVor loss adjustment.

Installation

You can install CVor using pip:

pip install cvor

Usage

Here's a quick example of how to use CVor:

import torch
from cvor import compute_cvor_loss

# Sample loss tensor
loss_input = torch.tensor([1.0, 2.0, 3.0], device='cuda')

# Compute CVor loss
loss = compute_cvor_loss(loss_input, method='NN', alpha=0.1)
print(loss)

Parameters

  • loss_input (Tensor): The input tensor representing loss.
  • method (str): The method for computing CVor loss. Options are 'AO', 'NN', and 'LOO'.
  • alpha (float): The adjustment coefficient. Must be between 0 and 1.

Requirements

  • Python 3.8+
  • PyTorch

Contributing

Contributions, issues, and feature requests are welcome. Feel free to check issues page if you want to contribute.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

CHEN XINGYAN - xychen@swufe.edu.cn

Project Link: https://github.com/uglyghost/cvor.git

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

CVor-0.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

CVor-0.0.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: CVor-0.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for CVor-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d3b6b98e0cb970a1cb88c1b700687129e4d82947131e05947136d484206d8dd6
MD5 a81a2ec2f0b46904249c87ae18c99aa9
BLAKE2b-256 b371b4f68c14e52286749ce1d5c2bae6e3b78a53fd57b166fc3bab6ce8cec181

See more details on using hashes here.

File details

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

File metadata

  • Download URL: CVor-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for CVor-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae4ebbaaeae2d51323e267ad438be670dcdc41d1ff2ddf46f782bd25cf06a73c
MD5 1f0dee6e069b8ce42b929e8a7029f8ac
BLAKE2b-256 0bca70efebac0acc9e0e51d868c41419be05a7cf8a56f8cddcfeb58fe8bbb385

See more details on using hashes here.

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