{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"# importamos librerias\nimport zipfile\nfrom fastai.vision import *\nwarnings.simplefilter(\"ignore\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"path = Path('../input/dogs-vs-cats-redux-kernels-edition/')\npath.ls()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"TRAIN_ZIP = path / 'train.zip'\nwith zipfile.ZipFile(TRAIN_ZIP, 'r') as z: z.extractall('data')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data = (ImageList.from_folder('data')\n                 .split_by_rand_pct(0.2)\n                 .label_from_func(lambda x: x.stem.split('.')[0])\n                 .transform(get_transforms(), size=224)\n                 .databunch(bs=32)\n                 .normalize())\ndata","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data.show_batch(3, figsize=(8,8))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Examinemos la data\nxb,yb = data.one_batch()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"xb.shape\n# [batch_size, channels (RGB), ancho, alto]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"yb\n# Tenemos 1 label por cada imagen","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"data.c2i","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Modelo"},{"metadata":{"trusted":true},"cell_type":"code","source":"learn = cnn_learner(data, models.resnet34, metrics=accuracy)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true},"cell_type":"code","source":"learn.fit_one_cycle(3, 1e-3)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"learn.show_results(DatasetType.Train, 4)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"interp = learn.interpret()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"interp.plot_confusion_matrix()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"interp.plot_top_losses(9)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"interp.plot_top_losses(9, largest=False, heatmap=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"interp.plot_top_losses(9, heatmap=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}