lixilinx / psgd_torch Goto Github PK
View Code? Open in Web Editor NEWPytorch implementation of preconditioned stochastic gradient descent (affine group preconditioner, low-rank approximation preconditioner and more)
Pytorch implementation of preconditioned stochastic gradient descent (affine group preconditioner, low-rank approximation preconditioner and more)
great work.
Could you write it as an optimizer, like adam, so that it can be used as a replacement of the optimizers in PyTorch
Hello, trying out your optimizer, and am running into training instability - NaN issues. Do you have any advice for debugging this?
The setup code is copied from your mnist - LeNet5 example (which converges without problem). See below for the drop-in.
The model in question is a modified transformer with L1 instead of dot-product attention; it converges with AdamW, SGD, AdaDelta (at varying speeds).
Posting an issue as this may affect other users.
loss = torch.sum((yp - y)**2) # simple MSE error
if use_AdamW:
loss.backward()
optimizer.step()
else:
grads = torch.autograd.grad(loss, model.parameters(), create_graph=True)
vs = [torch.randn_like(W) for W in model.parameters()]
Hvs = torch.autograd.grad(grads, model.parameters(), vs)
with torch.no_grad():
Qs = [psgd.update_precond_kron(Qlr[0], Qlr[1], v, Hv) for (Qlr, v, Hv) in zip(Qs, vs, Hvs)]
pre_grads = [psgd.precond_grad_kron(Qlr[0], Qlr[1], g) for (Qlr, g) in zip(Qs, grads)]
grad_norm = torch.sqrt(sum([torch.sum(g*g) for g in pre_grads]))
lr_adjust = min(grad_norm_clip_thr/grad_norm, 1.0)
[W.subtract_(lr_adjust*lr*g) for (W, g) in zip(model.parameters(), pre_grads)]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.