Skip to main content

MMCR Loss: Learning efficient coding of natural images with maximum manifold capacity representations

Project description

Pytorch implementation of Maximum Manifold Capacity Representations Loss

This is not an official implementation from the authors. Official implementation from the authors.

Maximum Manifold Capacity Representation Loss (MMCR Loss) is a novel objective function for self-supervised learning (SSL) proposed by researchers in Center for Neural Science, NYU.

This repository aims to offer a convenient MMCR loss module for PyTorch, which can be easily integrated into your projects using git clone or pip install.

How to install

pip3 install mmcr

or

git clone https://github.com/skyil7/mmcr
cd mmcr
pip install -e .

Usage

import torch
from mmcr import MMCRLoss

loss = MMCRLoss()

input_tensor = torch.randn((8, 16, 128))  # batch_size, n_aug, feature_dim
loss_val = loss(input_tensor)

print(loss_val)

How it works

\mathcal{L} = \lambda\frac{\sum^{N}_{i=1}\lVert z_{i} \rVert_{*}}{N} - \lVert C\rVert_{*}

Where $\lambda$ is a trade-off parameter, $\lVert z_i\rVert_*$ is local nuclear norm of the $i$-th sample's augmented matrix, and $\lVert C\rVert_*$ is the global nuclear norm of centroid matrix $C$.

Arguments

  • lmbda: Trade-off parameter $\lambda$. default is 0.
  • n_aug: number of augmented views. If your input tensor is 3-dimensional $(N, k, d)$, you don't need to specify it.

Original Implementation from the author

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

mmcr-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

mmcr-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file mmcr-0.1.0.tar.gz.

File metadata

  • Download URL: mmcr-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.5

File hashes

Hashes for mmcr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ec7118fc6512139cea16639e6014ddb315cc2fa1592cc0cd53cb3d1d963be7e7
MD5 6e8d36253bbb0542d1014f6726a4dd94
BLAKE2b-256 cc90aeb3c332e4ffe79a705d89a7e567a6958436e78d47096d8668024bf24da2

See more details on using hashes here.

File details

Details for the file mmcr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mmcr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.5

File hashes

Hashes for mmcr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23ac1c0efd919a6ba10491121b6681aa62fc740c43b8871d38312b89dda83cfd
MD5 f912be52422358a7ec7dd72f28d437b3
BLAKE2b-256 5f6e962a216df69f0ff7d4b8f1fbf0022f9b91bd755462d93b696eaa8cbc6420

See more details on using hashes here.

Supported by

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