Pytorch-lightning: Namespace Cleaning

Created on 22 Jul 2020  路  3Comments  路  Source: PyTorchLightning/pytorch-lightning

馃殌 Feature

Change how the namespace is cleaned to be fully general. Right now, it filters all callables, but this filters some things which are pickable and callable.

Motivation

Currently, users can interact with callable objects only in the init method. It's useful to use these elsewhere, for example I pass in optim.Adam or optim.SGD to switch between optimizers, more flexible than hardcoding strings.

Pitch

rewrite clean_namespace to be something like:

for k,v in hparams.items():
    try:
        pickle.dumps(v)
    except:
        del_attrs.append(k)
Refactors and code health enhancement help wanted

All 3 comments

@monney mind draft a PR to clarify what you mean?

@Borda I created a PR, it should also fix #2444 right now it's failing a test case, but my change shouldn't make it fail anything new. I tried the test case on my machine and it seems to work, so I'm not sure why it's failing

The test looks broken to me, it's checking for nn.CrossEntropyLoss, but it should be checking for nn.CosineEmbeddingLoss The version I have does that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

williamFalcon picture williamFalcon  路  3Comments

mmsamiei picture mmsamiei  路  3Comments

remisphere picture remisphere  路  3Comments

iakremnev picture iakremnev  路  3Comments

srush picture srush  路  3Comments