-
-
Save kiransair/8a1179ca68ca5243bff90c08b1df3bb9 to your computer and use it in GitHub Desktop.
SO_72380756.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "SO_72380756.ipynb", | |
"provenance": [], | |
"authorship_tag": "ABX9TyM12NN63euwl47yS/9trhqm", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/kiransair/8a1179ca68ca5243bff90c08b1df3bb9/so_72380756.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"id": "RHH-xzJALo9g" | |
}, | |
"outputs": [], | |
"source": [ | |
"import tensorflow as tf" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"base_model = tf.keras.applications.Xception(\n", | |
" weights='imagenet',\n", | |
" # image shape = 128x128x3\n", | |
" input_shape=(128, 128, 3),\n", | |
" include_top=False)\n", | |
"\n", | |
"# freeze layers\n", | |
"base_model.trainable = False\n", | |
"\n", | |
"inputs = tf.keras.Input(shape=(128, 128, 3))\n", | |
"#x = data_augmentation(inputs)\n", | |
"x = tf.keras.applications.xception.preprocess_input(inputs)\n", | |
"x = base_model(x, training=False)\n", | |
"x = tf.keras.layers.Flatten()(x)\n", | |
"x = tf.keras.layers.Dense(128, activation='relu')(x) \n", | |
"outputs = tf.keras.layers.Dense(1, activation='sigmoid')(x)\n", | |
"model = tf.keras.Model(inputs, outputs)" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "Jtyi26vTLpcf", | |
"outputId": "eeaa310a-337e-478f-c749-537dc5f7ad27" | |
}, | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/xception/xception_weights_tf_dim_ordering_tf_kernels_notop.h5\n", | |
"83689472/83683744 [==============================] - 1s 0us/step\n", | |
"83697664/83683744 [==============================] - 1s 0us/step\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"x=tf.random.uniform(shape=(1,128,128,3))\n", | |
"x= tf.keras.applications.xception.preprocess_input(x) " | |
], | |
"metadata": { | |
"id": "o3OXy9q9LrM7" | |
}, | |
"execution_count": 3, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"theModel=tf.keras.models.Sequential([ \n", | |
" tf.keras.Input(tensor=x),\n", | |
" base_model,\n", | |
" tf.keras.layers.Flatten(),\n", | |
" tf.keras.layers.Dense(128, activation='relu'),\n", | |
" tf.keras.layers.Dense(1,activation='sigmoid')\n", | |
"])" | |
], | |
"metadata": { | |
"id": "vXLH0VBVLs9S" | |
}, | |
"execution_count": 4, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"" | |
], | |
"metadata": { | |
"id": "3d3TKI8nLupy" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment