itzikmalkiel / mtadam Goto Github PK
View Code? Open in Web Editor NEWMTAdam: Automatic Balancing of Multiple Training Loss Terms
MTAdam: Automatic Balancing of Multiple Training Loss Terms
Hi,
thank you for this repo. I tried to use your optimizer, and I get the error:
Traceback (most recent call last):
File "train.py", line 241, in <module>
optimizer.step(loss_array, ranks, None)
File "/home/fdiakogiannis/Software/torch/optim/optimizer.py", line 89, in wrapper
return func(*args, **kwargs)
File "/home/fdiakogiannis/Software/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/home/fdiakogiannis/Projects/OI-FD-dev/src/training_scripts/nbeatsxx/model_v3_quantile_to/mtadam.py", line 64, in step
self.update_weights(loss_array, ranks)
File "/home/fdiakogiannis/Projects/OI-FD-dev/src/training_scripts/nbeatsxx/model_v3_quantile_to/mtadam.py", line 153, in update_weights
max_denom = p.denom[0]
AttributeError: 'Parameter' object has no attribute 'denom'
srun: error: hyades03: task 0: Exited with exit code 1
I tried to use MTAdam to combine L1Loss and BCELoss. The relative code entries I use are:
# Balanced Adam optimizer
from mtadam import *
...
optimizer = MTAdam(net.parameters(), lr=0.001)
...
# The first loss is L1 the second BCE Loss, as given by torch.nn.
loss_array = [criterion(ypreds, ylabel), criterion_pp(to_preds,to_label)]
ranks = [1]*len(loss_array)
optimizer.step(loss_array, ranks, None)
any ideas on how to overcome the problem? I am using the NGC NVIDIA container for pytorch.
Kind regards,
Foivos
Thanks for sharing, this is a simple and interesting way to use auxiliary losses.
When using it on a large dataset I get a memory leak, it uses up more and more cuda memory untill it crashes. I think this is because the graph is not cleared loss.backward(retain_graph=True).
The obvious next step is to clear the graph with a loss.backward(retain_graph=False) but I get an error that the variables have been modified. I assume this is an intentional or metabalance, but I can't find where, and I can't find a way to clear the graph manually.
Any tips?
Note I cross posted this to metabalance, probobly because it has the same issue, being based of MTAdam code.
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.