{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import datetime\n", "\n", "from util.util import importstr\n", "from util.logconf import logging\n", "log = logging.getLogger('nb')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def run(app, *argv):\n", " argv = list(argv)\n", " argv.insert(0, '--num-workers=4') # <1>\n", " log.info(\"Running: {}({!r}).main()\".format(app, argv))\n", " \n", " app_cls = importstr(*app.rsplit('.', 1)) # <2>\n", " app_cls(argv).main()\n", " \n", " log.info(\"Finished: {}.{!r}).main()\".format(app, argv))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import shutil\n", "\n", "# clean up any old data that might be around.\n", "# We don't call this by default because it's destructive, \n", "# and would waste a lot of time if it ran when nothing \n", "# on the application side had changed.\n", "def cleanCache():\n", " shutil.rmtree('data-unversioned/cache')\n", " os.mkdir('data-unversioned/cache')\n", "\n", "# cleanCache()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "training_epochs = 20\n", "experiment_epochs = 10\n", "final_epochs = 50\n", "\n", "training_epochs = 2\n", "experiment_epochs = 2\n", "final_epochs = 5\n", "seg_epochs = 10" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Chapter 11" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch11.prepcache.LunaPrepCacheApp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch11.training.LunaTrainingApp', '--epochs=1')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch11.training.LunaTrainingApp', f'--epochs={experiment_epochs}')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Chapter 12" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch12.prepcache.LunaPrepCacheApp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch12.training.LunaTrainingApp', '--epochs=1', 'unbalanced')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch12.training.LunaTrainingApp', f'--epochs={training_epochs}', '--balanced', 'balanced')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch12.training.LunaTrainingApp', f'--epochs={experiment_epochs}', '--balanced', '--augment-flip', 'flip')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch12.training.LunaTrainingApp', f'--epochs={experiment_epochs}', '--balanced', '--augment-offset', 'offset')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch12.training.LunaTrainingApp', f'--epochs={experiment_epochs}', '--balanced', '--augment-scale', 'scale')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch12.training.LunaTrainingApp', f'--epochs={experiment_epochs}', '--balanced', '--augment-rotate', 'rotate')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch12.training.LunaTrainingApp', f'--epochs={experiment_epochs}', '--balanced', '--augment-noise', 'noise')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch12.training.LunaTrainingApp', f'--epochs={training_epochs}', '--balanced', '--augmented', 'fully-augmented')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Chapter 13" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch13.prepcache.LunaPrepCacheApp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch13.training.LunaTrainingApp', f'--epochs={final_epochs}', '--balanced', '--augmented', 'final-cls')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "run('p2ch13.train_seg.LunaTrainingApp', f'--epochs={seg_epochs}', '--augmented', 'final-seg')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Chapter 14" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch14.prepcache.LunaPrepCacheApp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "run('p2ch14.training.ClassificationTrainingApp', f'--epochs=100', 'nodule-nonnodule')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "run('p2ch14.training.ClassificationTrainingApp', f'--epochs=40', '--malignant', '--dataset=MalignantLunaDataset',\n", " '--finetune=''data/part2/models/cls_2020-02-06_14.16.55_final-nodule-nonnodule.best.state',\n", " 'finetune-head')\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "run('p2ch14.training.ClassificationTrainingApp', f'--epochs=40', '--malignant', '--dataset=MalignantLunaDataset',\n", " '--finetune=''data/part2/models/cls_2020-02-06_14.16.55_final-nodule-nonnodule.best.state',\n", " '--finetune-depth=2',\n", " 'finetune-depth2')\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch14.nodule_analysis.NoduleAnalysisApp', '--run-validation')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "run('p2ch14.nodule_analysis.NoduleAnalysisApp', '--run-validation', '--malignancy-path')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 2 }