Giter Site home page Giter Site logo

amc's Introduction

Training neural networks using Metropolis Monte Carlo and an adaptive variant

This repository contains a pytorch implementation of the aMC optimizer as described in https://arxiv.org/abs/2205.07408, and tutorials on how it can be used to optimize neural networks on the MNIST data set.

General use

Any gradient-based optimizer can easily be replaced with the aMC optimizer. If the gradient-based optimizer is used as follows

optimizer = torch.optim.Adam(net.parameters(), lr = ...)

optimizer.zero_grad()
loss = loss_function(net(data),...)
loss.backward()
optimizer.step()

then the aMC optimizer can be used by defining a "closure" function which calculates the loss:

optimizer = aMC(net.parameters(), init_sigma = ...)

def loss_closure():
    loss = loss_function(net(data),...)
    return loss

optimizer.step(loss_closure)

while the rest of the training loop remains unchanged. Examples can be found in the tutorial files.

amc's People

Contributors

itamblyn avatar ccasert avatar

Stargazers

Sai Tanmay avatar Pete Dillon avatar Sushen Yadav avatar Martin Novák avatar Klejdi Sevdari avatar  avatar Mohammadreza Razavian avatar

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.