diff --git a/.travis.yml b/.travis.yml index 33d58fc10..da84d83a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,10 @@ python: 2.7 dist: trusty sudo: false +env: + global: + - NBCONVERT_ARGS="--to html --execute --ExecutePreprocessor.kernel_name=python --ExecutePreprocessor.timeout=-1" + install: # xvfb # https://docs.travis-ci.com/user/gui-and-headless-browsers/ @@ -32,7 +36,8 @@ script: curl -sSLO "http://files.fast.ai/data/dogscats.zip" && unzip -qq -d deeplearning1/nbs/data dogscats.zip; fi - - jupyter nbconvert --to html --execute deeplearning1/nbs/lesson1.ipynb --ExecutePreprocessor.kernel_name=python --ExecutePreprocessor.timeout=-1 + - travis_wait jupyter nbconvert deeplearning1/nbs/lesson1.ipynb $NBCONVERT_ARGS + - travis_wait jupyter nbconvert deeplearning1/nbs/lesson2.ipynb $NBCONVERT_ARGS before_cache: # We only cache the archives but not the extracted packages, diff --git a/deeplearning1/nbs/lesson2.ipynb b/deeplearning1/nbs/lesson2.ipynb index 0b844a6d9..ff5247cc3 100644 --- a/deeplearning1/nbs/lesson2.ipynb +++ b/deeplearning1/nbs/lesson2.ipynb @@ -374,8 +374,8 @@ }, "outputs": [], "source": [ - "#path = \"data/dogscats/sample/\"\n", - "path = \"data/dogscats/\"\n", + "path = \"data/dogscats/sample/\"\n", + "# path = \"data/dogscats/\"\n", "model_path = path + 'models/'\n", "if not os.path.exists(model_path): os.mkdir(model_path)" ] @@ -395,8 +395,8 @@ }, "outputs": [], "source": [ - "batch_size=100\n", - "#batch_size=4" + "# batch_size=100\n", + "batch_size=4" ] }, { @@ -1160,7 +1160,10 @@ "#3. The images we were most confident were cats, but are actually dogs\n", "incorrect_cats = np.where((preds==0) & (preds!=val_labels[:,1]))[0]\n", "most_incorrect_cats = np.argsort(probs[incorrect_cats])[::-1][:n_view]\n", - "plots_idx(incorrect_cats[most_incorrect_cats], probs[incorrect_cats][most_incorrect_cats])" + "if len(most_incorrect_cats):\n", + " plots_idx(incorrect_cats[most_incorrect_cats], probs[incorrect_cats][most_incorrect_cats])\n", + "else:\n", + " print('No incorrect cats!')" ] }, { @@ -1187,7 +1190,10 @@ "#3. The images we were most confident were dogs, but are actually cats\n", "incorrect_dogs = np.where((preds==1) & (preds!=val_labels[:,1]))[0]\n", "most_incorrect_dogs = np.argsort(probs[incorrect_dogs])[:n_view]\n", - "plots_idx(incorrect_dogs[most_incorrect_dogs], 1-probs[incorrect_dogs][most_incorrect_dogs])" + "if len(most_incorrect_dogs):\n", + " plots_idx(incorrect_dogs[most_incorrect_dogs], 1-probs[incorrect_dogs][most_incorrect_dogs])\n", + "else:\n", + " print('No incorrect dogs!')" ] }, { @@ -1519,8 +1525,8 @@ "outputs": [], "source": [ "def fit_model(model, batches, val_batches, nb_epoch=1):\n", - " model.fit_generator(batches, samples_per_epoch=batches.N, nb_epoch=nb_epoch, \n", - " validation_data=val_batches, nb_val_samples=val_batches.N)" + " model.fit_generator(batches, samples_per_epoch=batches.n, nb_epoch=nb_epoch, \n", + " validation_data=val_batches, nb_val_samples=val_batches.n)" ] }, { @@ -1958,7 +1964,7 @@ "outputs": [], "source": [ "model.load_weights(model_path+'finetune2.h5')\n", - "model.evaluate_generator(get_batches(path+'valid', gen, False, batch_size*2), val_batches.N)" + "model.evaluate_generator(get_batches(path+'valid', gen, False, batch_size*2), val_batches.n)" ] }, { diff --git a/requirements.txt b/requirements.txt index a731848ed..6522b7fcb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ theano tensorflow pandas scikit-learn -bcolz \ No newline at end of file +bcolz +sympy \ No newline at end of file