<jupyter_start><jupyter_text><jupyter_code>import tensorflow as tf

from tensorflow.keras.layers import Reshape, Dropout, Dense,Multiply, Dot, Concatenate,Embedding
from keras.applications.vgg16 import VGG16, preprocess_input
from keras.datasets import cifar10
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Conv2D, Flatten, Dropout, MaxPool2D,SeparableConv2D, ReLU, Add,GlobalAvgPool2D, Input,BatchNormalization 
#from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPool2D, SeparableConv2D,  BatchNormalization, Input, GlobalAveragePool2D
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.optimizers import Adam

import os
import numpy as np
import matplotlib.pyplot as plt
from PIL import ImageTk, Image
tf.__version__
train_image_generator = ImageDataGenerator(
                                              rotation_range=40,
                                              width_shift_range=0.2,
                                              height_shift_range=0.2,
                                              rescale=1./255,
                                              shear_range=0.2,
                                              zoom_range=0.2,
                                              horizontal_flip=True,
                                              fill_mode='nearest')
validation_image_generator = ImageDataGenerator(rescale=1./255) # Generator for our validation data
train_data_gen = train_image_generator.flow_from_directory(batch_size=32,
                                                           directory='/content/drive/My Drive/chest_xray/train',
                                                           shuffle=True,
                                                           target_size=(256, 256),
                                                           class_mode='binary')
test_data_gen = validation_image_generator.flow_from_directory(batch_size=32,
                                                           directory='/content/drive/My Drive/chest_xray/test',
                                                           shuffle=True,
                                                           target_size=(256, 256),
                                                           class_mode='binary')
#Let's look at how many cats and dogs images are in the training and validation directory:
total_train = train_data_gen.samples
total_val = test_data_gen.samples
print("Total training images:", total_train)
print("Total validation images:", total_val)
from tensorflow.keras.applications.inception_v3 import InceptionV3, preprocess_input
import tensorflow.keras as keras
from tensorflow.keras import models
from tensorflow.keras import layers
from tensorflow.keras import optimizers
import tensorflow as tf
from keras.utils import np_utils
from keras.models import load_model
from keras.preprocessing import image
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import cv2
#@title Default title text
conv_base = InceptionV3(weights='imagenet', include_top=False, input_shape=(256, 256, 3))
conv_base.summary()
model = models.Sequential()
model.add(conv_base)
model.add(layers.Flatten(input_shape=(256,256,3)))
model.add(layers.Dense(128, activation='tanh'))
model.add(layers.Dropout(0.5))
model.add(layers.BatchNormalization())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dropout(0.5))
model.add(layers.BatchNormalization())
model.add(layers.Dense(1, activation='sigmoid'))
model.compile(optimizer=optimizers.RMSprop(lr=2e-5), loss='binary_crossentropy', metrics=['acc'])

history = model.fit(train_data_gen, steps_per_epoch=5, epochs=20, batch_size=30, validation_data=test_data_gen)<jupyter_output>Epoch 1/20
5/5 [==============================] - 175s 35s/step - loss: 0.7805 - acc: 0.5125 - val_loss: 0.6588 - val_acc: 0.5897
Epoch 2/20
5/5 [==============================] - 162s 32s/step - loss: 0.6776 - acc: 0.6224 - val_loss: 0.6409 - val_acc: 0.6378
Epoch 3/20
5/5 [==============================] - 180s 36s/step - loss: 0.6484 - acc: 0.6750 - val_loss: 0.6528 - val_acc: 0.6218
Epoch 4/20
5/5 [==============================] - 179s 36s/step - loss: 0.7093 - acc: 0.6562 - val_loss: 0.6313 - val_acc: 0.6458
Epoch 5/20
5/5 [==============================] - 175s 35s/step - loss: 0.5957 - acc: 0.7125 - val_loss: 0.6166 - val_acc: 0.6779
Epoch 6/20
5/5 [==============================] - 171s 34s/step - loss: 0.7069 - acc: 0.6313 - val_loss: 0.6033 - val_acc: 0.7099
Epoch 7/20
5/5 [==============================] - 171s 34s/step - loss: 0.6040 - acc: 0.7125 - val_loss: 0.5751 - val_acc: 0.7019
Epoch 8/20
5/5 [==============================] - 174s 35s/step - loss: 0.7181 - acc: 0.64[...]
{'fraction_non_alphanumeric': 0.14050791007493754, 'fraction_numerical': 0.06473771856786012, 'mean_word_length': 2.4568345323741005, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '431620', 'license': 'MIT', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1363, 'n_words': 318, 'path': 'X_Ray_Classification_Inception_V3.ipynb', 'repo_name': 'Aanchal-eng/Deep-Learning-Coursera', 'size': '4804'}