Skip to content

Commit

Permalink
Visdom dashboard; clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
devforfu committed Sep 29, 2019
1 parent 9d7e377 commit dfce226
Show file tree
Hide file tree
Showing 20 changed files with 875 additions and 162 deletions.
11 changes: 9 additions & 2 deletions dev/00a_annotations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -18,6 +18,13 @@
"Func = Union[Callable, str]\n",
"Size = Tuple[int, int]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -36,7 +43,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.3"
},
"toc": {
"base_numbering": 1,
Expand Down
30 changes: 19 additions & 11 deletions dev/00b_config.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
" def batch_size(self) -> int: return 4\n",
" \n",
" @property\n",
" def bs(self) -> int: return self.batch_size\n",
"\n",
" @property\n",
" def cpu(self) -> torch.device: return torch.device('cpu')\n",
"\n",
" @property\n",
Expand All @@ -47,16 +44,18 @@
" def datasets(self) -> Path: return Path.home()/'data'\n",
" \n",
" @property\n",
" def loss_function(self) -> Loss: return F.nll_loss\n",
" \n",
" @property\n",
" def loss_fn(self) -> Loss: return self.loss_function\n",
" def loss_fn(self) -> Loss: return F.nll_loss\n",
" \n",
" @property\n",
" def num_workers(self) -> int: return cpu_count()\n",
" \n",
" @property\n",
" def n_jobs(self) -> int: return self.num_workers"
"\n",
" def __str__(self):\n",
" public = []\n",
" for prop in dir(self):\n",
" if prop.startswith('_'): \n",
" continue\n",
" public.append((prop, getattr(self, prop)))\n",
" return '\\n'.join([f'{key}: {value}' for key, value in public])"
]
},
{
Expand All @@ -68,6 +67,15 @@
"#export\n",
"defaults = Config()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(str(defaults))"
]
}
],
"metadata": {
Expand All @@ -86,7 +94,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.3"
},
"toc": {
"base_numbering": 1,
Expand Down
2 changes: 1 addition & 1 deletion dev/00c_utils.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.3"
},
"toc": {
"base_numbering": 1,
Expand Down
49 changes: 48 additions & 1 deletion dev/00d_mixins.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,53 @@
" params = ', '.join([f'{k}={v}' for k, v in self.get_params().items()])\n",
" return f'<{classname(self)}: {params}>'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class Transformer(ParametersMixin):\n",
" def __init__(self, position, key='value', **kwargs):\n",
" self.position = position\n",
" self.key = key"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"t = Transformer(1, 'parameter')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"t.get_params()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"t.set_params(position=999, key='xxx')\n",
"t.get_params()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -69,7 +116,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.3"
},
"toc": {
"base_numbering": 1,
Expand Down
40 changes: 33 additions & 7 deletions dev/01a_callbacks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,34 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"scrolled": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Exported: /home/ck/code/loop/dev/00a_annotations.ipynb -> loop/annotations.py\r\n",
"Exported: /home/ck/code/loop/dev/00b_config.ipynb -> loop/config.py\r\n",
"Exported: /home/ck/code/loop/dev/00c_utils.ipynb -> loop/utils.py\r\n",
"Exported: /home/ck/code/loop/dev/00d_mixins.ipynb -> loop/mixins.py\r\n",
"Exported: /home/ck/code/loop/dev/01a_callbacks.ipynb -> loop/callbacks.py\r\n",
"Exported: /home/ck/code/loop/dev/01b_modules.ipynb -> loop/modules.py\r\n",
"Exported: /home/ck/code/loop/dev/02a_metrics.ipynb -> loop/metrics.py\r\n",
"Exported: /home/ck/code/loop/dev/02b_phase.ipynb -> loop/phase.py\r\n",
"Exported: /home/ck/code/loop/dev/02c_training.ipynb -> loop/training.py\r\n",
"Exported: /home/ck/code/loop/dev/03a_schedule.ipynb -> loop/schedule.py\r\n",
"Exported: /home/ck/code/loop/dev/03b_early_stopping.ipynb -> loop/early_stopping.py\r\n",
"Exported: /home/ck/code/loop/dev/03c_predictions.ipynb -> loop/predictions.py\r\n",
"Exported: /home/ck/code/loop/dev/04a_debugging.ipynb -> loop/debugging.py\r\n",
"Exported: /home/ck/code/loop/dev/05a_text.ipynb -> loop/text.py\r\n",
"Exported: /home/ck/code/loop/dev/99_testing.ipynb -> loop/testing.py\r\n",
"15 notebook(s) exported into folder: loop\r\n"
]
}
],
"source": [
"!python export.py -o loop"
]
Expand All @@ -21,6 +44,7 @@
"source": [
"#export \n",
"from collections import defaultdict\n",
"from dataclasses import dataclass\n",
"from enum import IntFlag\n",
"from operator import itemgetter\n",
"import sys\n",
Expand Down Expand Up @@ -85,6 +109,7 @@
" def batch_ended(self, **kwargs): pass\n",
" def before_forward(self, **kwargs): pass\n",
" def after_forward(self, **kwargs): pass\n",
" def after_loss(self, **kwargs): pass\n",
" def before_backward(self, **kwargs): pass\n",
" def after_backward(self, **kwargs): pass\n",
" def interrupted(self, **kwargs): pass\n",
Expand Down Expand Up @@ -236,9 +261,9 @@
" Each observer has a backward reference to its group via 'group' attribute. The group\n",
" keeps a reference to the model which can be used by the \n",
" \"\"\"\n",
" def __init__(self, cbs, model=None):\n",
" def __init__(self, cbs, loop=None):\n",
" self._init(cbs)\n",
" self.model = model\n",
" self.loop = loop\n",
" \n",
" def __repr__(self):\n",
" names = '\\n'.join([f' {repr(cb)}' for cb in self.callbacks])\n",
Expand Down Expand Up @@ -269,6 +294,7 @@
" def batch_ended(self, **kwargs): self('batch_ended', **kwargs)\n",
" def before_forward(self, **kwargs): self('before_forward', **kwargs)\n",
" def after_forward(self, **kwargs): self('after_forward', **kwargs)\n",
" def after_loss(self, **kwargs): self('after_loss', **kwargs)\n",
" def before_backward(self, **kwargs): self('before_forward', **kwargs)\n",
" def after_backward(self, **kwargs): self('after_backward', **kwargs)\n",
" def interrupted(self, **kwargs): self('interrupted', **kwargs)\n",
Expand All @@ -277,8 +303,8 @@
" def __getattr__(self, item):\n",
" if item in vars(self):\n",
" return self.__dict__[item]\n",
" if self._model is not None:\n",
" return getattr(self._model, item)\n",
" if self.loop is not None:\n",
" return getattr(self.loop, item)\n",
" raise AttributeError(item)\n",
" \n",
" def __getitem__(self, item):\n",
Expand Down Expand Up @@ -314,7 +340,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.3"
},
"toc": {
"base_numbering": 1,
Expand Down
Loading

0 comments on commit dfce226

Please sign in to comment.