Skip to main content

A pytorch model training protocol for environment invariant deployment

Project description

This is a PyTorch implementation of the Inter-environmental Gradient Alignment algorithm proposed by Koyama and Yamaguchi in their paper Out-of-Distribution Generalization with Maximal Invariant Predictor

Quick start

Install pytorch-iga in the terminal:

pip install pytorch-iga

Import IGA in python:

from iga import IGA

IGA is defined with the following parameters:

IGA(model, optimizer, criterion, data, num_epochs, batch_size, lamda, verbose=10, device=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
)

Parameters:

model (torch.nn.Module): neural network model to be trained/tuned optimizer (torch.optim): pytorch optimizer object such as torch.optim.SGD criterion (function): loss function for model evaluation data (list(torch.utils.Dataset)): a list of Datasets for each environment num_epochs (int): number of training epochs batch_size (int): number of data points per batch lamda (float): importance weight of inter-environmental variance verbose (int): number of iterations in each progress log device (torch.device): optional, torch.device object, defaults to 'cuda' or 'cpu'

Returns:

model (torch.nn.Module): updated torch model IGA_loss (float): ending loss value

Example

to be continued...

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

pytorch-iga-0.0.3.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

pytorch_iga-0.0.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file pytorch-iga-0.0.3.tar.gz.

File metadata

  • Download URL: pytorch-iga-0.0.3.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pytorch-iga-0.0.3.tar.gz
Algorithm Hash digest
SHA256 6e43ce378b0d6022f7f99d460beb850d591b29eb32a56efbd99c947d526d2732
MD5 f1eee0c488221ada1a6a6dbc98d94fbd
BLAKE2b-256 8743dc9251e266e68895ff4544e699210696ff77d930c30ce306f3e3c6d1bcc5

See more details on using hashes here.

File details

Details for the file pytorch_iga-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pytorch_iga-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pytorch_iga-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fa7d83670f3c9d965c6bf58f2f18d7f2fc6197e2d05814fedf097bbe8d704e39
MD5 4212db0cf4ffb0e8cf50a4f7bff6f2e8
BLAKE2b-256 1e6bde1917be8a4381353c7a1c6dcd42d5559c1ca44ddb835c6d5ec4c8f5ce71

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