diff --git a/06_TransferLearning_Cheetahs.ipynb b/06_TransferLearning_Cheetahs.ipynb index 0b666b3352a4f48c9cdf31e560af82828ed14167..f020d03269f1392896c93e44e9c7c3ac5f33ae20 100644 --- a/06_TransferLearning_Cheetahs.ipynb +++ b/06_TransferLearning_Cheetahs.ipynb @@ -6,7 +6,7 @@ "source": [ "# Übung 6: Transfer learning\n", "\n", - "Gruppe 2: Albrecht Oster, Linus Helfmann" + "Gruppe 2: Albrecht Oster, Linus Helfmann\n" ] }, { @@ -36,12 +36,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T20:52:44.530667Z", - "start_time": "2018-04-15T20:52:41.160191Z" - } - }, + "metadata": {}, "outputs": [ { "name": "stderr", @@ -75,12 +70,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T20:52:44.537661Z", - "start_time": "2018-04-15T20:52:44.532660Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "EPOCHEN=3\n", @@ -92,12 +82,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T20:53:01.019333Z", - "start_time": "2018-04-15T20:52:44.540663Z" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -150,12 +135,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T20:53:01.173303Z", - "start_time": "2018-04-15T20:53:01.022281Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "model = Sequential()\n", @@ -177,19 +157,15 @@ "model.add(Flatten())\n", "model.add(Dense(1000, activation='relu'))\n", "model.add(Dense(3, activation='softmax'))\n", - "model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])\n", + "model.compile(optimizer='rmsprop', loss='categorical_crossentropy', \\\n", + " metrics=['accuracy'])\n", "#model.summary()" ] }, { "cell_type": "code", "execution_count": 5, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:00:02.052086Z", - "start_time": "2018-04-15T20:53:01.176284Z" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -218,12 +194,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:00:02.061113Z", - "start_time": "2018-04-15T21:00:02.055090Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "def classes2BinaryForROC(array):\n", @@ -236,18 +207,14 @@ " print(cm)\n", " print(\"Accuracy:\",(cm[0,0]+cm[1,1]+cm[2,2])/(cm.sum()))\n", " \n", - " print(\"ROC AUC\",roc_auc_score(classes2BinaryForROC(val),classes2BinaryForROC(predict)))" + " print(\"ROC AUC\",roc_auc_score(classes2BinaryForROC(val), \\\n", + " classes2BinaryForROC(predict)))" ] }, { "cell_type": "code", "execution_count": 7, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:00:16.126793Z", - "start_time": "2018-04-15T21:00:02.064089Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "predict = model.predict_generator(val_gen)" @@ -256,12 +223,7 @@ { "cell_type": "code", "execution_count": 8, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:00:16.147780Z", - "start_time": "2018-04-15T21:00:16.129771Z" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -296,12 +258,7 @@ { "cell_type": "code", "execution_count": 9, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:00:26.832784Z", - "start_time": "2018-04-15T21:00:16.150772Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "from keras.applications.inception_v3 import InceptionV3\n", @@ -313,7 +270,8 @@ "modelInceptionV3 = InceptionV3(weights='imagenet', include_top=True)\n", "\n", "# compile the model\n", - "modelInceptionV3.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])" + "modelInceptionV3.compile(optimizer='rmsprop', loss='categorical_crossentropy', \\\n", + " metrics=['accuracy'])" ] }, { @@ -326,12 +284,7 @@ { "cell_type": "code", "execution_count": 10, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:00:42.810125Z", - "start_time": "2018-04-15T21:00:26.834774Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "predict_original = modelInceptionV3.predict_generator(val_gen)" @@ -340,12 +293,7 @@ { "cell_type": "code", "execution_count": 11, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:00:42.826126Z", - "start_time": "2018-04-15T21:00:42.813125Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "predict_labels = np.argmax(predict_original, axis=1)\n", @@ -368,12 +316,7 @@ { "cell_type": "code", "execution_count": 12, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:00:42.843126Z", - "start_time": "2018-04-15T21:00:42.829128Z" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -407,12 +350,7 @@ { "cell_type": "code", "execution_count": 13, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:00:56.296178Z", - "start_time": "2018-04-15T21:00:42.847126Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "from keras.applications.inception_v3 import InceptionV3\n", @@ -437,18 +375,14 @@ " layer.trainable = False\n", "\n", "# compile the model (should be done *after* setting layers to non-trainable)\n", - "model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])" + "model.compile(optimizer='rmsprop', loss='categorical_crossentropy', \\\n", + " metrics=['accuracy'])" ] }, { "cell_type": "code", "execution_count": 14, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:07:49.981356Z", - "start_time": "2018-04-15T21:00:56.298161Z" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -488,12 +422,7 @@ { "cell_type": "code", "execution_count": 15, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:08:04.433674Z", - "start_time": "2018-04-15T21:07:49.984359Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "predict = model.predict_generator(val_gen)" @@ -502,12 +431,7 @@ { "cell_type": "code", "execution_count": 16, - "metadata": { - "ExecuteTime": { - "end_time": "2018-04-15T21:08:04.449677Z", - "start_time": "2018-04-15T21:08:04.437678Z" - } - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -582,10 +506,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.5" + "version": "3.6.4" }, "toc": { - "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, diff --git a/06_TransferLearning_Cheetahs.pdf b/06_TransferLearning_Cheetahs.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ee4b5b295e807d3f34448c7ea542b196fdd1215d Binary files /dev/null and b/06_TransferLearning_Cheetahs.pdf differ