Skip to main content

torch-parameter-groups Build Status codecov PyPI version

Group PyTorch Parameters according to Rules.

Installation

Need Python 3.6+.

pip install torch-parameter-groups

Usage

import torch
import torch.nn as nn
import torch_basic_models
import torch_parameter_groups


model = torch_basic_models.MobileNetV2.factory()
optimizer = torch_parameter_groups.optimizer_factory(
    model=model,
    config={
        'type': 'SGD',
        'kwargs': {
            'momentum': 0.9,
            'nesterov': True,
            'weight_decay': 0.0001,
        },
        'rules': [
            {
                'param_name_list': ['weight'],
                'kwargs': {
                    'weight_decay': 0
                }
            },
            {
            }
        ]
    },
)

criterion = nn.CrossEntropyLoss()
output = model(torch.randn(1, 3, 224, 224))
loss = criterion(output, torch.Tensor([0]).long())
loss.backward()
optimizer.step(closure=None)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torch-parameter-groups-0.0.5.post1.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file torch-parameter-groups-0.0.5.post1.tar.gz.

File metadata

  • Download URL: torch-parameter-groups-0.0.5.post1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.3

File hashes

Hashes for torch-parameter-groups-0.0.5.post1.tar.gz
Algorithm Hash digest
SHA256 ea9d3aa3290cd5cde56b5c4df7a24178d62ad0fd196c37cdd6e3ec3f17ae43ae
MD5 3c3f28545650d193ede2f3b51ba7aab4
BLAKE2b-256 2a4a026bb9d13dd766b8ac35c6f938d01f2b85720923a7caa6d16aabdc59fbf0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.5.post1 This release

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

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