From 2e0ef134e148e401d4bded0979ceca2932a72786 Mon Sep 17 00:00:00 2001 From: keon Date: Sat, 17 Aug 2019 22:33:28 -0700 Subject: [PATCH] remove maplotlib inline configuration --- .../00-image-recovery.py" | 2 +- .../01-fashion-mnist.py" | 2 +- .../01-basic-autoencoder.py" | 2 +- .../02-denoising-autoencoder.py" | 2 +- .../02-sequence-to-sequence.py" | 2 +- .../01-fgsm-attack.py" | 2 +- compile_notebooks.py | 2 ++ 7 files changed, 8 insertions(+), 6 deletions(-) diff --git "a/03-\355\214\214\354\235\264\355\206\240\354\271\230\353\241\234_\352\265\254\355\230\204\355\225\230\353\212\224_\354\235\270\352\263\265_\354\213\240\352\262\275\353\247\235/00-image-recovery.py" "b/03-\355\214\214\354\235\264\355\206\240\354\271\230\353\241\234_\352\265\254\355\230\204\355\225\230\353\212\224_\354\235\270\352\263\265_\354\213\240\352\262\275\353\247\235/00-image-recovery.py" index da11507..b84f9dd 100644 --- "a/03-\355\214\214\354\235\264\355\206\240\354\271\230\353\241\234_\352\265\254\355\230\204\355\225\230\353\212\224_\354\235\270\352\263\265_\354\213\240\352\262\275\353\247\235/00-image-recovery.py" +++ "b/03-\355\214\214\354\235\264\355\206\240\354\271\230\353\241\234_\352\265\254\355\230\204\355\225\230\353\212\224_\354\235\270\352\263\265_\354\213\240\352\262\275\353\247\235/00-image-recovery.py" @@ -9,7 +9,7 @@ # 우리의 목표는 오염된 이미지와 weird_function()의 코드만을 가지고 원본 이미지 파일을 복원하는 것입니다. # *참고자료: https://github.com/jcjohnson/pytorch-examples, NYU Intro2ML* -get_ipython().run_line_magic('matplotlib', 'inline') + import torch import pickle import matplotlib.pyplot as plot diff --git "a/04-\353\224\245\353\237\254\353\213\235\354\234\274\353\241\234_\355\214\250\354\205\230_\354\225\204\354\235\264\355\205\234_\352\265\254\353\266\204\355\225\230\352\270\260/01-fashion-mnist.py" "b/04-\353\224\245\353\237\254\353\213\235\354\234\274\353\241\234_\355\214\250\354\205\230_\354\225\204\354\235\264\355\205\234_\352\265\254\353\266\204\355\225\230\352\270\260/01-fashion-mnist.py" index 4d802e2..131a581 100644 --- "a/04-\353\224\245\353\237\254\353\213\235\354\234\274\353\241\234_\355\214\250\354\205\230_\354\225\204\354\235\264\355\205\234_\352\265\254\353\266\204\355\225\230\352\270\260/01-fashion-mnist.py" +++ "b/04-\353\224\245\353\237\254\353\213\235\354\234\274\353\241\234_\355\214\250\354\205\230_\354\225\204\354\235\264\355\205\234_\352\265\254\353\266\204\355\225\230\352\270\260/01-fashion-mnist.py" @@ -3,7 +3,7 @@ # # 4.1 Fashion MNIST 데이터셋 알아보기 -get_ipython().run_line_magic('matplotlib', 'inline') + from torchvision import datasets, transforms, utils from torch.utils import data diff --git "a/06-\354\202\254\353\236\214\354\235\230_\354\247\200\353\217\204_\354\227\206\354\235\264_\355\225\231\354\212\265\355\225\230\353\212\224_\354\230\244\355\206\240\354\235\270\354\275\224\353\215\224/01-basic-autoencoder.py" "b/06-\354\202\254\353\236\214\354\235\230_\354\247\200\353\217\204_\354\227\206\354\235\264_\355\225\231\354\212\265\355\225\230\353\212\224_\354\230\244\355\206\240\354\235\270\354\275\224\353\215\224/01-basic-autoencoder.py" index 95f7f0b..7c7e570 100644 --- "a/06-\354\202\254\353\236\214\354\235\230_\354\247\200\353\217\204_\354\227\206\354\235\264_\355\225\231\354\212\265\355\225\230\353\212\224_\354\230\244\355\206\240\354\235\270\354\275\224\353\215\224/01-basic-autoencoder.py" +++ "b/06-\354\202\254\353\236\214\354\235\230_\354\247\200\353\217\204_\354\227\206\354\235\264_\355\225\231\354\212\265\355\225\230\353\212\224_\354\230\244\355\206\240\354\235\270\354\275\224\353\215\224/01-basic-autoencoder.py" @@ -12,7 +12,7 @@ from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm import numpy as np -get_ipython().run_line_magic('matplotlib', 'inline') + torch.manual_seed(1) # reproducible diff --git "a/06-\354\202\254\353\236\214\354\235\230_\354\247\200\353\217\204_\354\227\206\354\235\264_\355\225\231\354\212\265\355\225\230\353\212\224_\354\230\244\355\206\240\354\235\270\354\275\224\353\215\224/02-denoising-autoencoder.py" "b/06-\354\202\254\353\236\214\354\235\230_\354\247\200\353\217\204_\354\227\206\354\235\264_\355\225\231\354\212\265\355\225\230\353\212\224_\354\230\244\355\206\240\354\235\270\354\275\224\353\215\224/02-denoising-autoencoder.py" index eaa22f6..8669ce3 100644 --- "a/06-\354\202\254\353\236\214\354\235\230_\354\247\200\353\217\204_\354\227\206\354\235\264_\355\225\231\354\212\265\355\225\230\353\212\224_\354\230\244\355\206\240\354\235\270\354\275\224\353\215\224/02-denoising-autoencoder.py" +++ "b/06-\354\202\254\353\236\214\354\235\230_\354\247\200\353\217\204_\354\227\206\354\235\264_\355\225\231\354\212\265\355\225\230\353\212\224_\354\230\244\355\206\240\354\235\270\354\275\224\353\215\224/02-denoising-autoencoder.py" @@ -25,7 +25,7 @@ from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm import numpy as np -get_ipython().run_line_magic('matplotlib', 'inline') + torch.manual_seed(1) # reproducible diff --git "a/07-\354\210\234\354\260\250\354\240\201\354\235\270_\353\215\260\354\235\264\355\204\260\353\245\274_\354\262\230\353\246\254\355\225\230\353\212\224_RNN/02-sequence-to-sequence.py" "b/07-\354\210\234\354\260\250\354\240\201\354\235\270_\353\215\260\354\235\264\355\204\260\353\245\274_\354\262\230\353\246\254\355\225\230\353\212\224_RNN/02-sequence-to-sequence.py" index 60c90eb..a3eb039 100644 --- "a/07-\354\210\234\354\260\250\354\240\201\354\235\270_\353\215\260\354\235\264\355\204\260\353\245\274_\354\262\230\353\246\254\355\225\230\353\212\224_RNN/02-sequence-to-sequence.py" +++ "b/07-\354\210\234\354\260\250\354\240\201\354\235\270_\353\215\260\354\235\264\355\204\260\353\245\274_\354\262\230\353\246\254\355\225\230\353\212\224_RNN/02-sequence-to-sequence.py" @@ -11,7 +11,7 @@ import torch.nn.functional as F import random -get_ipython().run_line_magic('matplotlib', 'inline') + vocab_size = 256 # 총 아스키 코드 개수 diff --git "a/08-\353\224\245\353\237\254\353\213\235_\355\225\264\355\202\271\355\225\230\352\270\260/01-fgsm-attack.py" "b/08-\353\224\245\353\237\254\353\213\235_\355\225\264\355\202\271\355\225\230\352\270\260/01-fgsm-attack.py" index c0f290b..c83b00f 100644 --- "a/08-\353\224\245\353\237\254\353\213\235_\355\225\264\355\202\271\355\225\230\352\270\260/01-fgsm-attack.py" +++ "b/08-\353\224\245\353\237\254\353\213\235_\355\225\264\355\202\271\355\225\230\352\270\260/01-fgsm-attack.py" @@ -16,7 +16,7 @@ import json -get_ipython().run_line_magic('matplotlib', 'inline') + import matplotlib.pyplot as plt diff --git a/compile_notebooks.py b/compile_notebooks.py index 3ae8fa7..408b584 100644 --- a/compile_notebooks.py +++ b/compile_notebooks.py @@ -23,6 +23,7 @@ def main(): exporter = ScriptExporter() cell_pattern = "#\s(In)\[(.*)\]:\n\n\n" # # In [*]: comment_pattern = "(#(\s*)\n)" + matplotlib_pattern = "(.*get_ipython.*)" for nbpath in glob.iglob('**/*.ipynb', recursive=True): base, ext = os.path.splitext(nbpath) @@ -31,6 +32,7 @@ def main(): # remove unecessary patterns script = re.sub(cell_pattern, "", script) script = re.sub(comment_pattern, "", script) + script = re.sub(matplotlib_pattern, "", script) pypath = (base + resources.get('output_extension', '.txt')) print("Saving script %s" % pypath) with io.open(pypath, 'w', encoding='utf-8') as f: