Skip to main content
Documentation Status

1. Introduction

In meta learner scenario, it is common use dependent variables as parameters, and back propagate the gradient of the parameters. However, parameters of PyTorch Module are designed to be leaf nodes and it is forbidden for parameters to have grad_fn. Meta learning coders are therefore forced to rewrite the basic layers to adapt the meta learning requirements.

This module provide an extension of torch.nn.Module, DependentModule that has dependent parameters, allowing the differentiable dependent parameters. It also provide the method to transform nn.Module into DependentModule, and turning all of the parameters of a nn.Module into dependent parameters.

2. Installation

pip install MetaNN

3. Example

PyTorch suggest all parameters of a module to be independent variables. Using DependentModule arbitrary torch.nn.module can be transformed into dependent module.

from metann import DependentModule
from torch import nn
net = torch.nn.Sequential(
    nn.Linear(10, 100),
    nn.Linear(100, 5))
net = DependentModule(net)
print(net)

Higher-level api such as MAML class are more recommended to use.

from metann.meta import MAML, default_evaluator_classification as evaluator
from torch import nn
net = torch.nn.Sequential(
    nn.Linear(10, 100),
    nn.Linear(100, 5))
)
maml = MAML(net, steps_train=5, steps_eval=10, lr=0.01)
output = maml(data_train)
loss = evaluator(output, data_test)
loss.backward()

4. Documents

The documents are available at ReadTheDocs. MetaNN

5. License

MIT

Copyright (c) 2019-present, Hanqiao Yu

Release files for MetaNN 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MetaNN 0.3.2
File Size Uploaded
MetaNN-0.3.2.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for MetaNN 0.3.2
File Interpreter ABI Platform
MetaNN-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / MetaNN-0.3.2.tar.gz

Download URL MetaNN-0.3.2.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2123e383deedf10ca8ccae3b8c517c7cf6f18309bf77e867dc5cbe6aa2f52713
BLAKE2b-256 checksum
How to use checksums
6c03f8b81237ad7930ed19b3b7e4cdc5aa5ef4c60cc1936cdb102558d993bcb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

Release files / MetaNN-0.3.2-py3-none-any.whl

Download URL MetaNN-0.3.2-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32ba23844d6782ec7ac825614e5700114da17ae81eb652f251ce31fe7b69672b
BLAKE2b-256 checksum
How to use checksums
2888169e64638a7d226176a44a30cb498dded12731ef64058def4f6dc29d1536
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release 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