Code Monkey home page Code Monkey logo

meta-weight-net_code-optimization's Introduction

Meta-Weight-Net_Code-Optimization

A new code framework that uses pytorch to implement meta-learning, and takes Meta-Weight-Net as an example.


By using a trick, meta-learning and meta-networks have become plug-and-play. We can now apply the meta learning algorithm directly to the existing pytorch model without rewriting it.

This code takes Meta-Weight-Net (Meta-Weight-Net: Learning an Explicit Mapping For Sample Weighting) as an example to show how to use this trick. It rewrites an optimizer to assign non leaf node tensors to model parameters. See meta.py and line 90-120 of main.py for details.

Environment

  • python 3.8
  • pytorch 1.9.0
  • torchvision 0.10.0

noisy_long_tail_CIFAR.py can generate noisy and long-tailed CIFAR datasets by calling torchvision.datasets. Because some class attributes' names have been changed, errors may occur in some earlier versions of torchvision. It can be solved by changing the corresponding attribute name.

Running this example

ResNet32 on CIFAR10-LT with imbalanced factor of 50:

python main.py --imbalanced_factor 50

ResNet32 on CIFAR10 with 40% uniform noise:

python main.py --meta_lr 1e-3 --meta_weight_decay 1e-4 --corruption_type uniform --corruption_ratio 0.4

Resuilt(CIFAR10)

Data Setting Test Accuracy
imbalanced factor 50 80.43%
imbalanced factor 100 75.92%
imbalanced factor 200 68.89%
40% uniform noise 87.83%

Acknowledgements

Thanks to the original code of Meta-Weight-Net (https://github.com/xjtushujun/meta-weight-net).

Contact: Shi Yunyi ([email protected])

meta-weight-net_code-optimization's People

Contributors

shiyunyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

meta-weight-net_code-optimization's Issues

The Training results cannot be fixed

First of all, thank you very much for your work!

I am using Resnet18 imported by pytorch (pretrain =true) and using my own dataset for image classification. Even with the default parameters (with random seeds), I find that the testing results are inconsistent across epochs of repeated training. What should I think about this from?

Looking forward to your reply. Thanks

Is there possible to replace SGD with Adam

Hi, thank you very much for the code. And, I wonder why you rewrite the SGD as MetaSGD and is there any possible to use the Adam
algorithm while training the ResNet.

RuntimeError: One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior.

Hi, thank you very much for your work.
When I use my own dataset and model, It error in this Line:
pseudo_grads = torch.autograd. grad(pseudo_loss, pseudo_net.parameters(), create_graph=True)

The following error message is displayed:

RuntimeError: One of the differentiated Tensors appears to not have been used in the graph. Set allow_unused=True if this is the desired behavior.

Looking forward to your reply.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.