Cockpit is a visual and statistical debugger specifically designed for deep learning.

Related tags

Deep Learningcockpit
Overview

Logo

A Practical Debugging Tool for Training Deep Neural Networks

A better status screen for deep learning.

InstallationDocsLicenseCitation

CI Lint Doc Coverage License: MIT Code style: black arXiv


pip install 'git+https://github.com/f-dangel/cockpit.git'

Cockpit is a visual and statistical debugger specifically designed for deep learning. Training a deep neural network is often a pain! Successfully training such a network usually requires either years of intuition or expensive parameter searches involving lots of trial and error. Traditional debuggers provide only limited help: They can find syntactical errors but not training bugs such as ill-chosen learning rates. Cockpit offers a closer, more meaningful look into the training process with multiple well-chosen instruments.


CockpitAnimation

Installation

To install Cockpit simply run

pip install 'git+https://github.com/f-dangel/cockpit.git'

Documentation

The documentation provides a full tutorial on how to get started using Cockpit as well as a detailed documentation of its API.

Experiments

To showcase the capabilities of Cockpit we performed several experiments illustrating the usefulness of our debugging tool. For a discussion of those experiments please refer to our paper.

License

Distributed under the MIT License. See LICENSE for more information.

Citation

If you use Cockpit, please consider citing:

Frank Schneider, Felix Dangel, Philipp Hennig
Cockpit: A Practical Debugging Tool for Training Deep Neural Networks
arXiv 2102.06604

@misc{schneider2021cockpit,
   title={{Cockpit: A Practical Debugging Tool for Training Deep Neural Networks}},
   author={Frank Schneider and Felix Dangel and Philipp Hennig},
   year={2021},
   eprint={2102.06604},
   archivePrefix={arXiv},
   primaryClass={cs.LG}
}
Comments
  • [BUG] Using `Alpha` with other quantities and a custom optimizer

    [BUG] Using `Alpha` with other quantities and a custom optimizer

    No support yet for custom optimizers?


    Error(log below) while trying cockpit with custom optimizer class(that subclasses torch.optim.Optimizer). Although seems to work as expected with in-built optimizers (torch.optim.SGD).

    Log

    Traceback (most recent call last): File "laplace_primer.py", line 137, in sgld.train(prefinal_train, train_loader, model) File "../SGLD_laplace.py", line 123, in train loss.backward(create_graph=cockpit.create_graph(epochs)) File "./miniconda3/envs/backpack/lib/python3.7/site-packages/cockpit/context.py", line 137, in exit self.cp.track(self.global_step, protected_savefields=self.protected_savefields) File "../miniconda3/envs/backpack/lib/python3.7/site-packages/cockpit/cockpit.py", line 178, in track q.track(global_step, self.params, batch_loss) File "../miniconda3/envs/backpack/lib/python3.7/site-packages/cockpit/quantities/quantity.py", line 87, in track iteration, result = self.compute(global_step, params, batch_loss) File "./miniconda3/envs/backpack/lib/python3.7/site-packages/cockpit/quantities/quantity.py", line 516, in compute save_result = self._compute(global_step, params, batch_loss) File "../miniconda3/envs/backpack/lib/python3.7/site-packages/cockpit/quantities/quantity.py", line 538, in _compute self._compute_start(global_step, params, batch_loss) File "../miniconda3/envs/backpack/lib/python3.7/site-packages/cockpit/quantities/alpha.py", line 280, in _compute_start self._save_1st_order_info(global_step, params, batch_loss, point, until) File "../miniconda3/envs/backpack/lib/python3.7/site-packages/cockpit/quantities/alpha.py", line 332, in _save_1st_order_info id(p): batch_size * p.grad_batch.data.clone().detach() for p in params File "../miniconda3/envs/backpack/lib/python3.7/site-packages/cockpit/quantities/alpha.py", line 332, in id(p): batch_size * p.grad_batch.data.clone().detach() for p in params AttributeError: 'Parameter' object has no attribute 'grad_batch'

    🐛 Type: Bug 👍 Status: Done 
    opened by nmndeep 8
  • Plotter crashes when using `show_plot=False, save_plot=True`

    Plotter crashes when using `show_plot=False, save_plot=True`

    Description

    Plotting to a file crashes (see stacktrace below). Calling plot with show_plot=True, save_plot=True works and results in the file being saved correctly. The issue is reproducible over multiple runs and thus probably not caused by weird gradients etc.

    Steps to Reproduce

    1. Setup
    config = [
                    quantities.Distance(schedules.linear(interval=1)),
                    quantities.GradHist1d(schedules.linear(interval=1)),
                    quantities.GradNorm(schedules.linear(interval=1)),
                    quantities.InnerTest(schedules.linear(interval=1)),
                    quantities.Loss(schedules.linear(interval=1)),
                    quantities.NormTest(schedules.linear(interval=1)),
                    quantities.OrthoTest(schedules.linear(interval=1)),
                    quantities.UpdateSize(schedules.linear(interval=1)),
                    quantities.GradHist2d(schedules.linear(interval=1))
                ]
                self._cockpit = Cockpit(model.parameters(), quantities=config)
                self._cockpit_plotter = CockpitPlotter()
    
    1. Track a few backward steps

    2. Call plot with show_plot=False and save_plot=True

    self._cockpit_plotter.plot(self._cockpit,
                                            savedir=cockpit_log_dir,
                                            show_plot=False,
                                            save_plot=True)
    

    Traceback (most recent call last):
      File "code/train.py", line 215, in <module>
        metrics = main(opts)
      File "code/train.py", line 185, in main
        training_info = trainer.train(model, dataset, eval_data, logger)
      File "./code/trainers/mse_trainer.py", line 186, in train
        self.log(logger.root_dir)
      File "./code/trainers/base_trainer.py", line 145, in log
        save_plot=True)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/plotter.py", line 142, in plot
        self._plot_gradients(self.grid_spec[0, 1])
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/plotter.py", line 223, in _plot_gradients
        instruments.gradient_tests_gauge(self, self.fig, self.gs_gradients[1, 1])
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/instruments/gradient_tests_gauge.py", line 69, in gradient_tests_gauge
        _format(self, ax_all, ax_norm, ax_inner, ax_ortho)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/instruments/gradient_tests_gauge.py", line 91, in _format
        ax_norm.set_yscale("log")
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 3708, in set_yscale
        ax.yaxis._set_scale(value, **kwargs)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/axis.py", line 800, in _set_scale
        self._scale.set_default_locators_and_formatters(self)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/scale.py", line 406, in set_default_locators_and_formatters
        axis.set_major_locator(LogLocator(self.base))
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/axis.py", line 1651, in set_major_locator
        self.stale = True
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/artist.py", line 230, in stale
        self.stale_callback(self, val)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/artist.py", line 51, in _stale_axes_callback
        self.axes.stale = val
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/artist.py", line 230, in stale
        self.stale_callback(self, val)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/figure.py", line 51, in _stale_figure_callback
        self.figure.stale = val
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/artist.py", line 230, in stale
        self.stale_callback(self, val)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/pyplot.py", line 589, in _auto_draw_if_interactive
        fig.canvas.draw_idle()
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 1907, in draw_idle
        self.draw(*args, **kwargs)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line 388, in draw
        self.figure.draw(self.renderer)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
        return draw(artist, renderer, *args, **kwargs)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/figure.py", line 1709, in draw
        renderer, self, artists, self.suppressComposite)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/image.py", line 135, in _draw_list_compositing_images
        a.draw(renderer)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
        return draw(artist, renderer, *args, **kwargs)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 2647, in draw
        mimage._draw_list_compositing_images(renderer, self, artists)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/image.py", line 135, in _draw_list_compositing_images
        a.draw(renderer)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
        return draw(artist, renderer, *args, **kwargs)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/axis.py", line 1203, in draw
        ticks_to_draw = self._update_ticks()
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/axis.py", line 1079, in _update_ticks
        major_locs = self.get_majorticklocs()
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/axis.py", line 1324, in get_majorticklocs
        return self.major.locator()
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/ticker.py", line 2271, in __call__
        return self.tick_values(vmin, vmax)
      File "./envs/pytorch/lib/python3.7/site-packages/matplotlib/ticker.py", line 2297, in tick_values
        "Data has no positive values, and therefore can not be "
    ValueError: Data has no positive values, and therefore can not be log-scaled.
    
    🐛 Type: Bug 🆕 Status: New 
    opened by mseitzer 5
  • [BUG] Extension hook executes on custom module

    [BUG] Extension hook executes on custom module

    Cockpit crashes with non descriptive error.

    Description

    I am trying to run cockpit on a simple network trained with MSE loss (although implemented through custom modules, not nn.Sequential). As far as I can see, no unsupported operations are involved (Linear, Sequential, Tanh, Identity).

    Cockpit crashes on computing the BatchGrad extension. Using backpack to compute the batch gradient works without crashes.

    Steps to Reproduce

    1. Setup
    self.loss_fn = lambda pred, target: ((target - pred) ** 2).mean(dim=-1)
    
    self._cockpit = Cockpit(model.parameters(),
                                        quantities=configuration("economy"))
    model = MyCustomModel()
    model = extend(model)
    optimizer = torch.optim.Adam(params=model.parameters(), lr=1e-3)
    
    1. Training Step
    pred = model(inp)
    loss = self.loss_fn(pred, target)
    mean_loss = loss.mean()
    
    optimizer.zero_grad()
    info = {
        "batch_size": len(loss),
        "individual_losses": loss,
        "loss": mean_loss,
        "optimizer": optimizer,
    }
    with self._cockpit(step, info=info, debug=True):
        create_graph = self._cockpit.create_graph(step)
        mean_loss.backward(create_graph=create_graph)  # CRASH HERE
    optimizer.step()
    

    Source or Possible Fix


    Stacktrace

    [DEBUG, step 0]
     ↪Quantities  : [<cockpit.quantities.alpha.Alpha object at 0x7fa751af5f10>, <cockpit.quantities.distance.Distance object at 0x7fa74e7c0cd0>, <cockpit.quantities.grad_hist.GradHist1d object at 0x7fa74e7c0d10>, <cockpit.quantities.grad_norm.GradNorm object at 0x7fa74e7c0d90>, <cockpit.quantities.inner_test.InnerTest object at 0x7fa74e7c0dd0>, <cockpit.quantities.loss.Loss object at 0x7fa74e7cd050>, <cockpit.quantities.norm_test.NormTest object at 0x7fa74e7cd090>, <cockpit.quantities.ortho_test.OrthoTest object at 0x7fa74e7cd0d0>, <cockpit.quantities.update_size.UpdateSize object at 0x7fa74e7cd110>]
     ↪Extensions  : [<backpack.extensions.firstorder.batch_grad.BatchGrad object at 0x7fa74e7cd750>]
     ↪Hooks       : <cockpit.quantities.utils_transforms.BatchGradTransformsHook object at 0x7fa74e7931d0>
     ↪Create graph: False
     ↪Save memory : True
    [DEBUG] Running extension <backpack.extensions.firstorder.batch_grad.BatchGrad object at 0x7fa74e7cd750> on Linear(in_features=128, out_features=1, bias=True)
    [DEBUG] Running extension <backpack.extensions.firstorder.batch_grad.BatchGrad object at 0x7fa74e7cd750> on LinearHead(
      (l): Linear(in_features=128, out_features=1, bias=True)
    )
    [DEBUG] Running extension <backpack.extensions.firstorder.batch_grad.BatchGrad object at 0x7fa74e7cd750> on Identity()
    [DEBUG] Running extension <backpack.extensions.firstorder.batch_grad.BatchGrad object at 0x7fa74e7cd750> on Sequential(
      (0): Linear(in_features=1, out_features=128, bias=True)
      (1): Tanh()
      (2): Linear(in_features=128, out_features=128, bias=True)
      (3): Tanh()
      (4): LinearHead(
        (l): Linear(in_features=128, out_features=1, bias=True)
      )
      (5): Identity()
    )
    [DEBUG] Running extension <backpack.extensions.firstorder.batch_grad.BatchGrad object at 0x7fa74e7cd750> on MLP(
      (layers): Sequential(
        (0): Linear(in_features=1, out_features=128, bias=True)
        (1): Tanh()
        (2): Linear(in_features=128, out_features=128, bias=True)
        (3): Tanh()
        (4): LinearHead(
          (l): Linear(in_features=128, out_features=1, bias=True)
        )
        (5): Identity()
      )
    )
    Traceback (most recent call last):
      File "./envs/pytorch/lib/python3.7/site-packages/backpack/__init__.py", line 169, in run_extension_hook
        CTX.get_extension_hook()(module)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/hooks/base.py", line 53, in __call__
        self.run_hook(param, module)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/hooks/base.py", line 80, in run_hook
        value = self.module_hook(param, module)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/hooks/base.py", line 139, in module_hook
        return self.param_hook(param)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/utils_transforms.py", line 78, in param_hook
        param.grad_batch._param_weakref = weakref.ref(param)
    AttributeError: 'Parameter' object has no attribute 'grad_batch'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "./code/trainers/base_trainer.py", line 112, in backward
        mean_loss.backward(create_graph=create_graph)
      File "./envs/pytorch/lib/python3.7/site-packages/torch/tensor.py", line 221, in backward
        torch.autograd.backward(self, gradient, retain_graph, create_graph)
      File "./envs/pytorch/lib/python3.7/site-packages/torch/autograd/__init__.py", line 132, in backward
        allow_unreachable=True)  # allow_unreachable flag
      File "./envs/pytorch/lib/python3.7/site-packages/backpack/__init__.py", line 151, in hook_run_extensions
        run_extension_hook(module)
      File "./envs/pytorch/lib/python3.7/site-packages/backpack/__init__.py", line 172, in run_extension_hook
        raise RuntimeError(f"Post extensions hook failed: {message}")
    RuntimeError: Post extensions hook failed: AttributeError("'Parameter' object has no attribute 'grad_batch'")
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "code/train.py", line 215, in <module>
        metrics = main(opts)
      File "code/train.py", line 185, in main
        training_info = trainer.train(model, dataset, eval_data, logger)
      File "./code/trainers/mse_trainer.py", line 128, in train
        self.backward(global_step, loss, mean_loss, optimizer)
      File "./code/trainers/base_trainer.py", line 112, in backward
        mean_loss.backward(create_graph=create_graph)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/context.py", line 137, in __exit__
        self.cp.track(self.global_step, protected_savefields=self.protected_savefields)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/cockpit.py", line 178, in track
        q.track(global_step, self.params, batch_loss)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/quantity.py", line 87, in track
        iteration, result = self.compute(global_step, params, batch_loss)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/quantity.py", line 516, in compute
        save_result = self._compute(global_step, params, batch_loss)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/quantity.py", line 538, in _compute
        self._compute_start(global_step, params, batch_loss)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/alpha.py", line 280, in _compute_start
        self._save_1st_order_info(global_step, params, batch_loss, point, until)
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/alpha.py", line 326, in _save_1st_order_info
        grad_dict = {id(p): p.grad.data.clone().detach() for p in params}
      File "./envs/pytorch/lib/python3.7/site-packages/cockpit/quantities/alpha.py", line 326, in <dictcomp>
        grad_dict = {id(p): p.grad.data.clone().detach() for p in params}
    AttributeError: 'NoneType' object has no attribute 'data'
    
    
    🐛 Type: Bug 👷 Status: In Progress 
    opened by mseitzer 5
  • GSNR computation incorrect?

    GSNR computation incorrect?

    I have a question regarding the scaling of the GSNR computation as provided in Cockpit

    Description

    In the following gist, I've written 3 different ways of computing the GSNR as defined in this paper, the same one cited in the Cockpit paper:

    1. Extracting the variance directly from the sample-wise gradients, via BackPACK BatchGrad() extension (bad, memory inefficient)
    2. Using the Variance() BackPACK extension (efficient & straightforward)
    3. Using a replacement formula for the variance to avoid sample-wise grad squaring: Var(X) = E[X²] - E[X]² (likely faster, less straightforward)

    https://gist.github.com/andres-fr/db9d0ba31d1502df62a09d382e504d1e

    Specifically, the first and second reflect the mathematical definition from the paper:

    GSNR_paper = grad_squared / Var(gradients)
    

    And this is the implementation of the replacement formula that I found to be equivalent:

    GSNR_gist = grad_squared / ( (sum_grad_squared / batch_size) - (grad_squared / (batch_size**2)) + epsilon)
    

    My issue/question is when I compare the last expression to the one in the Cockpit source code, a clear difference can be noticed in the batch scaling:

    GSNR_cockpit = grad_squared / (batch_size * sum_grad_squared - grad_squared + epsilon)
    

    When I used this last expression in my gist, it led to results clearly different from the other approaches. Am I missing something here? Is cockpit doing some further scaling under the hood? Or are these results scaled differently from the definition for some reason?


    Steps to Reproduce

    The gist works on CPU and CUDA. For easier reproduction, the gist depends on PyTorch and BackPACK only. The script docstring includes steps to install a minimal working conda environment. Then, simply run the script.

    Source or Possible Fix

    The BackPACK docs already warned about scaling issues with the Variance, which may even involve the loss function, so I wonder if this is a bug/feature.

    Intuitively, I'd say it is good if the quantity matches the definition from the paper, but again, implicit scaling may be getting in the way?

    🐛 Type: Bug 🆕 Status: New 
    opened by andres-fr 4
  • Plots from remote machine

    Plots from remote machine

    I am running some experiments on a remote machine, and I can't see any cockpit plot. I have the same problem when running the basic example. Is there a way of solving this? Am I missing something?

    This may be a dumb question, sorry I am quite new to this.

    Thank you!

    ❔ Type: Question 🐛 Type: Bug 👷 Status: In Progress 
    opened by Niccolo-Ajroldi 4
  • Monai 3D Resnet models

    Monai 3D Resnet models

    Hi!

    Thank you for this project, indeed it is quite interesting work.

    I am curious to know that if we can use it to interpret/observe the training of a 3D resnet model?

    Regards

    ❔ Type: Question 
    opened by Mushtaqml 4
  • No explicit loss and individual loss

    No explicit loss and individual loss

    Description

    What should I do if my model returns the tuple of loss and individual losses and I have no explicit loss function class?

    At the moment if I just extend the model, I get:

    cockpit/quantities/alpha.py in <dictcomp>(.0)
        324         self.save_to_cache(global_step, f"params_{point}", params_dict, block_fn)
        325 
    --> 326         grad_dict = {id(p): p.grad.data.clone().detach() for p in params}
        327         self.save_to_cache(global_step, f"grad_{point}", grad_dict, block_fn)
        328 
    
    AttributeError: 'NoneType' object has no attribute 'data'
    

    Thanks for any suggestions!

    🐛 Type: Bug 
    opened by kashif 4
  • Allow specifying extra parameters to `fig.savefig` in `CockpitPlotter.plot`

    Allow specifying extra parameters to `fig.savefig` in `CockpitPlotter.plot`

    Description

    I suggest to extend CockpitPlotter.plot such that a keyword dictionary can be passed to it specifying parameters to fig.savefig. This is to be able to choose 1) a DPI value or 2) a different file format (e.g. PDF).

    Currently, the stored image files have a poor resolution and thus are not very readable. Being able to choose a DPI value or saving to PDF would fix this issue.

    🆕 Status: New 
    opened by mseitzer 4
  • Plotter accepts savedir parameter but turns it into file path

    Plotter accepts savedir parameter but turns it into file path

    Description

    Plotter has a savedir parameter for which the documentation says it specifies the directory where to save the plot to. However, the _save function interprets this parameter as a file path: https://github.com/f-dangel/cockpit/blob/937b3eac8d9fef7e6e6fbc9c91863dd08b1362b1/cockpit/plotter.py#L400-L405

    This means plotting with savedir='/example/path' would result in a file /example/path__primary.png, where /example/path/__primary.png would be expected.

    Besides, when choosing to not display the plot, I don't think __primary or __secondary should be added to the filename. From an API standpoint, it would probably be best to let the user flexibly choose the path and filename to save to (potentially adding the image extension).

    🐛 Type: Bug 🆕 Status: New 
    opened by mseitzer 3
  • Learning rates and HyperParameters

    Learning rates and HyperParameters

    Hi!

    I am trying to replicate the plots you show, but I'm not able to find Learning Rates and HyperParameters on the json file created. Where can I find them?

    Also, I was wondering if I can find the descriptions of the quantities somewhere in the documentation. I found a table with names and descriptions, but for example the dimensions are not explained and for some quantities I am not able to understand why they have such dimensions on the json file.

    Thanks a lot!

    Bests, Cristian

    ❔ Type: Question 
    opened by Cmeo97 2
  • Gradient analysis from named parameters without backpack

    Gradient analysis from named parameters without backpack

    I have cockpit mostly working except I get this warnings like this because I have not implemented backpack's batch grad for all my modules:

    /usr/local/lib/python3.9/site-packages/backpack/extensions/backprop_extension.py:106: UserWarning: Extension saving to grad_batch does not have an extension for Module <class 'pycompress.model_parts.PredHist'> although the module has parameters 
    

    So as a result I am not able to get all the quantities without error. I understand backpack is central to the design of cockpit but I am fine with some things not working when I just want to prototype quickly.

    My questions/requests are:

    1. I still see the gradient histogram. Is that histogram only including the gradients for modules where the backpack extension worked or is it all of them?
    2. Have you thought about integrating the much smaller project https://github.com/alwynmathew/gradflow-check. They provide a chart that lets you check for vanishing gradient and they do it without backpack based on just having the named_parameters
    3. Unrelated but btw: Have you thought about including the ESD of the weight matrices as done in? https://github.com/CalculatedContent/WeightWatcher

    Thank you for your excellent work on this project!

    ❔ Type: Question 
    opened by jogardi 2
  • Support for Transformers

    Support for Transformers

    Requesting a new feature (I can't seem to add a label myself).

    Description

    Do you currently support Huggingface Transformers? In particular, I'd like to debug T5.

    I tried an editable install of Transformers, and modifying the PyTorch implementation underneath, but I can't quite get the two different loss functions to play together properly. For example, I'm trying to steal this implementation from the Basic Examples, and add it to Transformers:

    loss_fn = extend(torch.nn.CrossEntropyLoss(reduction="mean"))
    individual_loss_fn = torch.nn.CrossEntropyLoss(reduction="none")
    

    After 30 minutes of tinkering, I can't get arround this error. Thanks for any assistance.

    AssertionError: BackPACK extension expects a backpropagation quantity but it is None. Module: Linear(in_features=768, out_features=32128, bias=False), Extension: <backpack.extensions.secondorder.diag_hessian.DiagHessian object at 0x7f6a72f102b0>.
    
    During handling of the above exception, another exception occurred:
    
    AttributeError                            Traceback (most recent call last)
    Cell In[6], line 80
         69 # loss.sum().backward()
         70 # backward pass
         71 with cockpit(
         72     global_step,
         73     info={
       (...)
         78     },
         79 ):
    ---> 80     loss.sum().backward(create_graph=cockpit.create_graph(global_step))
         82 # optimizer step
         83 optimizer.step()
    
    File ~/githubs/cockpit/cockpit/context.py:155, in BackwardCTX.__exit__(self, type, value, traceback)
        152 for ctx in self.contexts:
        153     ctx.__exit__(type, value, traceback)
    --> 155 self.cp.track(self.global_step, protected_savefields=self.protected_savefields)
        157 CockpitCTX.erase()
    
    File ~/githubs/cockpit/cockpit/cockpit.py:195, in Cockpit.track(self, global_step, protected_savefields)
        190 before_cleanup = [
        191     q for q in self.quantities if not isinstance(q, quantities.HessMaxEV)
        192 ]
        194 for q in before_cleanup:
    --> 195     q.track(global_step, self.params, batch_loss)
        197 self._free_backpack_buffers(global_step, protected_savefields)
        199 after_cleanup = [
        200     q for q in self.quantities if isinstance(q, quantities.HessMaxEV)
        201 ]
    
    File ~/githubs/cockpit/cockpit/quantities/quantity.py:101, in Quantity.track(self, global_step, params, batch_loss)
         92 """Perform scheduled computations and store result.
         93 
         94 Args:
       (...)
    ...
    --> 335 grad_dict = {id(p): p.grad.data.clone().detach() for p in params}
        336 self.save_to_cache(global_step, f"grad_{point}", grad_dict, block_fn)
        338 # L = ¹/ₙ ∑ᵢ ℓᵢ, BackPACK's BatchGrad computes ¹/ₙ ∇ℓᵢ, we have to rescale
    
    AttributeError: 'NoneType' object has no attribute 'data'
    

    Update: after 2 more hours of tinkering, I'm pretty sure I am exactly matching your examples, but I'm still facing the exact same issue.

    BTW, I think I found this project at NeurIPS. Great work on it!

    🆕 Status: New 
    opened by KastanDay 1
Releases(v1.0.2)
Owner
Felix Dangel
Machine Learning PhD student at the University of Tübingen and the Max Planck Institute for Intelligent Systems.
Felix Dangel
Spherical CNNs

Spherical CNNs Equivariant CNNs for the sphere and SO(3) implemented in PyTorch Overview This library contains a PyTorch implementation of the rotatio

Jonas Köhler 893 Dec 28, 2022
torchbearer: A model fitting library for PyTorch

Note: We're moving to PyTorch Lightning! Read about the move here. From the end of February, torchbearer will no longer be actively maintained. We'll

632 Dec 13, 2022
Official implementation of NPMs: Neural Parametric Models for 3D Deformable Shapes - ICCV 2021

NPMs: Neural Parametric Models Project Page | Paper | ArXiv | Video NPMs: Neural Parametric Models for 3D Deformable Shapes Pablo Palafox, Aljaz Bozic

PabloPalafox 109 Nov 22, 2022
Released code for Objects are Different: Flexible Monocular 3D Object Detection, CVPR21

MonoFlex Released code for Objects are Different: Flexible Monocular 3D Object Detection, CVPR21. Work in progress. Installation This repo is tested w

Yunpeng 169 Dec 06, 2022
ShapeGlot: Learning Language for Shape Differentiation

ShapeGlot: Learning Language for Shape Differentiation Created by Panos Achlioptas, Judy Fan, Robert X.D. Hawkins, Noah D. Goodman, Leonidas J. Guibas

Panos 32 Dec 23, 2022
Basit bir burç modülü.

Bu modulu burclar hakkinda gundelik bir sekilde bilgi alin diye yaptim ve sizler icin kullanima sunuyorum. Modulun kullanimi asiri basit: Ornek Kullan

Special 17 Jun 08, 2022
Implementation of Transformer in Transformer, pixel level attention paired with patch level attention for image classification, in Pytorch

Transformer in Transformer Implementation of Transformer in Transformer, pixel level attention paired with patch level attention for image c

Phil Wang 272 Dec 23, 2022
Label-Free Model Evaluation with Semi-Structured Dataset Representations

Label-Free Model Evaluation with Semi-Structured Dataset Representations Prerequisites This code uses the following libraries Python 3.7 NumPy PyTorch

8 Oct 06, 2022
GeneGAN: Learning Object Transfiguration and Attribute Subspace from Unpaired Data

GeneGAN: Learning Object Transfiguration and Attribute Subspace from Unpaired Data By Shuchang Zhou, Taihong Xiao, Yi Yang, Dieqiao Feng, Qinyao He, W

Taihong Xiao 141 Apr 16, 2021
Multi-Task Pre-Training for Plug-and-Play Task-Oriented Dialogue System

Multi-Task Pre-Training for Plug-and-Play Task-Oriented Dialogue System Authors: Yixuan Su, Lei Shu, Elman Mansimov, Arshit Gupta, Deng Cai, Yi-An Lai

Amazon Web Services - Labs 123 Dec 23, 2022
Here is the diagnostic tool for BMVC 2021 paper Diagnosing Errors in Video Relation Detectors.

Here is the diagnostic tool for BMVC 2021 paper Diagnosing Errors in Video Relation Detectors. We provide a tiny ground truth file demo_gt.json, and t

Shuo Chen 3 Dec 26, 2022
Randstad Artificial Intelligence Challenge (powered by VGEN). Soluzione proposta da Stefano Fiorucci (anakin87) - primo classificato

Randstad Artificial Intelligence Challenge (powered by VGEN) Soluzione proposta da Stefano Fiorucci (anakin87) - primo classificato Struttura director

Stefano Fiorucci 1 Nov 13, 2021
Pytorch implementation of ICASSP 2022 paper Attention Probe: Vision Transformer Distillation in the Wild

Attention Probe: Vision Transformer Distillation in the Wild Jiahao Wang, Mingdeng Cao, Shuwei Shi, Baoyuan Wu, Yujiu Yang In ICASSP 2022 This code is

IIGROUP 6 Sep 21, 2022
Converts geometry node attributes to built-in attributes

Attribute Converter Simplifies converting attributes created by geometry nodes to built-in attributes like UVs or vertex colors, as a single click ope

Ivan Notaros 12 Dec 22, 2022
I explore rock vs. mine prediction using a SONAR dataset

I explore rock vs. mine prediction using a SONAR dataset. Using a Logistic Regression Model for my prediction algorithm, I intend on predicting what an object is based on supervised learning.

Jeff Shen 1 Jan 11, 2022
f-BRS: Rethinking Backpropagating Refinement for Interactive Segmentation

f-BRS: Rethinking Backpropagating Refinement for Interactive Segmentation [Paper] [PyTorch] [MXNet] [Video] This repository provides code for training

Visual Understanding Lab @ Samsung AI Center Moscow 516 Dec 21, 2022
Check out the StyleGAN repo and place it in the same directory hierarchy as the present repo

Variational Model Inversion Attacks Kuan-Chieh Wang, Yan Fu, Ke Li, Ashish Khisti, Richard Zemel, Alireza Makhzani Most commands are in run_scripts. W

Jackson Wang 15 Dec 26, 2022
Animatable Neural Radiance Fields for Modeling Dynamic Human Bodies

To make the comparison with Animatable NeRF easier on the Human3.6M dataset, we save the quantitative results at here, which also contains the results of other methods, including Neural Body, D-NeRF,

ZJU3DV 359 Jan 08, 2023
RoboDesk A Multi-Task Reinforcement Learning Benchmark

RoboDesk A Multi-Task Reinforcement Learning Benchmark If you find this open source release useful, please reference in your paper: @misc{kannan2021ro

Google Research 66 Oct 07, 2022
Deep Learning Emotion decoding using EEG data from Autism individuals

Deep Learning Emotion decoding using EEG data from Autism individuals This repository includes the python and matlab codes using for processing EEG 2D

Juan Manuel Mayor Torres 12 Dec 08, 2022