Leaving a note here to adjust the solution above for cell magic (e.g. %%time), with nbconvert > 6.0.
In nbconvert_config.py:
def comment_magics(input, **kwargs):
if input.startswith("%"):
input = "# " + input
return input| import socket | |
| import pandas as pd | |
| class MetricLogger: | |
| def __init__(self, root="runs"): | |
| self.metrics = {} | |
| self.iteration = 0 |
Leaving a note here to adjust the solution above for cell magic (e.g. %%time), with nbconvert > 6.0.
In nbconvert_config.py:
def comment_magics(input, **kwargs):
if input.startswith("%"):
input = "# " + input
return input| perf record -F 320 --call-graph dwarf python some_script.py | |
| perf script > out.perf | |
| # Visualize as flame graphs: https://github.com/brendangregg/FlameGraph | |
| ~/FlameGraph/stackcollapse-perf.pl out.perf > out.folded | |
| ~/FlameGraph/flamegraph.pl out.folded > out.svg | |
| google-chrome out.svg |
| import pandas as pd | |
| import json | |
| def read_json(filename): | |
| with open(filename, "r") as f: | |
| data = f.read() | |
| # TODO remove characters before first "{" from log directly instead |
| #! /bin/bash | |
| #SBATCH --job-name=torchaudiomodel | |
| #SBATCH --output=/checkpoint/%u/jobs/audio-%j.out | |
| #SBATCH --error=/checkpoint/%u/jobs/audio-%j.err | |
| #SBATCH --signal=USR1@600 | |
| #SBATCH --open-mode=append | |
| #SBATCH --partition=learnfair | |
| #SBATCH --time=4320 | |
| #SBATCH --mem-per-cpu=5120 |
| import torch | |
| from .optimizer import Optimizer | |
| class RMSprop(Optimizer): | |
| r"""Implements RMSprop algorithm. | |
| Proposed by G. Hinton in his | |
| `course <http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf>`_. | |
| The centered version first appears in `Generating Sequences | |
| With Recurrent Neural Networks <https://arxiv.org/pdf/1308.0850v5.pdf>`_. |
| import torch | |
| from .optimizer import Optimizer | |
| class RMSprop(Optimizer): | |
| r"""Implements RMSprop algorithm. | |
| Proposed by G. Hinton in his | |
| `course <http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf>`_. | |
| The centered version first appears in `Generating Sequences | |
| With Recurrent Neural Networks <https://arxiv.org/pdf/1308.0850v5.pdf>`_. |
| from itertools import repeat | |
| class StridedBuffer: | |
| def __init__(self, generator, stride, length): | |
| self._generator = generator | |
| self._stride = stride | |
| self._length = length | |
| self._buffer = [[] for _ in repeat(None, stride)] |