Giter Club home page Giter Club logo

Comments (3)

BenjaminBossan avatar BenjaminBossan commented on May 14, 2024

Proposal for NeuralNet.__repr__():

    def __repr__(self):
        params = self.get_params(deep=False)

        if self.initialized_:
            parts = ['initialized ' + str(self.__class__) + ' (']
        else:
            parts = ['uninitialized ' + str(self.__class__) + ' (']

        if params['history']:
            history = params.pop('history')
            params['history'] = 'history=[...],  # {} epochs'.format(len(history))

        for key, val in sorted(params.items()):
            val = str(val)
            if '\n' in val:
                val = '\n  '.join(val.split('\n'))
            parts.append('  {}={},'.format(key, val))

        parts.append(')')
        return '\n'.join(parts)

Result for an uninitialized net (module from notebook):

net = net = MyNet(
    MyModule,
    max_epochs=20,
    lr=0.1,
    module__num_units=123,
    module__dropout=0.33,
    optim__lr=0.22,
    iterator_train__shuffle=True,
    callbacks=[callbacks.EpochTimer, ('epoch2', callbacks.EpochTimer())],
    callbacks__epoch2__foo='bar',
)

# ==>

uninitialized <class '__main__.MyNet'> (
  batch_size=128,
  callbacks=[<class 'inferno.callbacks.EpochTimer'>, ('epoch2', <inferno.callbacks.EpochTimer object at 0x7fc530540160>)],
  callbacks__epoch2__foo=bar,
  cold_start=True,
  criterion=<class 'torch.nn.modules.loss.NLLLoss'>,
  dataset=<class 'inferno.dataset.Dataset'>,
  gradient_clip_norm_type=2,
  gradient_clip_value=None,
  history=None,
  initialized_=False,
  iterator_test=<class 'torch.utils.data.dataloader.DataLoader'>,
  iterator_train=<class 'torch.utils.data.dataloader.DataLoader'>,
  iterator_train__shuffle=True,
  lr=0.1,
  max_epochs=20,
  module=<class '__main__.MyModule'>,
  module__dropout=0.33,
  module__num_units=123,
  optim=<class 'torch.optim.sgd.SGD'>,
  optim__lr=0.22,
  train_split=<inferno.dataset.CVSplit object at 0x7fc535cacc50>,
  use_cuda=False,
  verbose=1,
)

After fitting:

initialized <class '__main__.MyNet'> (
  batch_size=128,
  callbacks=[<class 'inferno.callbacks.EpochTimer'>, ('epoch2', <inferno.callbacks.EpochTimer object at 0x7fc530540160>)],
  callbacks_=[('epoch_timer', <inferno.callbacks.EpochTimer object at 0x7fc535c98fd0>), ('train_loss', <inferno.callbacks.Scoring object at 0x7fc535d14828>), ('valid_loss', <inferno.callbacks.Scoring object at 0x7fc535d14f28>), ('valid_acc', <inferno.callbacks.Scoring object at 0x7fc59ad08e10>), ('EpochTimer', <inferno.callbacks.EpochTimer object at 0x7fc530534a90>), ('epoch2', <inferno.callbacks.EpochTimer object at 0x7fc530540160>), ('print_log', <inferno.callbacks.PrintLog object at 0x7fc59acf6f98>)],
  callbacks__epoch2__foo=bar,
  cold_start=True,
  criterion=<class 'torch.nn.modules.loss.NLLLoss'>,
  criterion_=NLLLoss (
  ),
  dataset=<class 'inferno.dataset.Dataset'>,
  gradient_clip_norm_type=2,
  gradient_clip_value=None,
  history=history=[...],  # 20 epochs,
  initialized_=True,
  iterator_test=<class 'torch.utils.data.dataloader.DataLoader'>,
  iterator_train=<class 'torch.utils.data.dataloader.DataLoader'>,
  iterator_train__shuffle=True,
  lr=0.1,
  max_epochs=20,
  module=<class '__main__.MyModule'>,
  module_=MyModule (
    (dense0): Linear (20 -> 123)
    (dropout): Dropout (p = 0.33)
    (dense1): Linear (123 -> 10)
    (output): Linear (10 -> 2)
  ),
  module__dropout=0.33,
  module__num_units=123,
  optim=<class 'torch.optim.sgd.SGD'>,
  optim_=<torch.optim.sgd.SGD object at 0x7fc530540198>,
  optim__lr=0.22,
  train_split=<inferno.dataset.CVSplit object at 0x7fc535cacc50>,
  use_cuda=False,
  verbose=1,
)

from skorch.

ottonemo avatar ottonemo commented on May 14, 2024

I think the current representation works well and #126 resolved this issue.
What's your opionion @benjamin-work?

from skorch.

BenjaminBossan avatar BenjaminBossan commented on May 14, 2024

IMO good enough for now.

from skorch.

Related Issues (20)

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.