1-
21import tensorflow as tf
3- from keras .models import Model
4- from keras .applications import MobileNetV2 , ResNet50 , InceptionV3 # try to use them and see which is better
5- from keras .layers import Dense
6- from keras .callbacks import ModelCheckpoint , TensorBoard
7- from keras .utils import get_file
8- from keras .preprocessing .image import ImageDataGenerator
2+ from tensorflow . keras .models import Model
3+ from tensorflow . keras .applications import MobileNetV2 , ResNet50 , InceptionV3 # try to use them and see which is better
4+ from tensorflow . keras .layers import Dense
5+ from tensorflow . keras .callbacks import ModelCheckpoint , TensorBoard
6+ from tensorflow . keras .utils import get_file
7+ from tensorflow . keras .preprocessing .image import ImageDataGenerator
98import os
109import pathlib
1110import numpy as np
@@ -65,7 +64,7 @@ def create_model(input_shape):
6564 # print the summary of the model architecture
6665 model .summary ()
6766
68- # training the model using rmsprop optimizer
67+ # training the model using adam optimizer
6968 model .compile (loss = "categorical_crossentropy" , optimizer = "adam" , metrics = ["accuracy" ])
7069 return model
7170
@@ -81,8 +80,8 @@ def create_model(input_shape):
8180 model_name = "MobileNetV2_finetune_last5"
8281
8382 # some nice callbacks
84- tensorboard = TensorBoard (log_dir = f "logs/ { model_name } " )
85- checkpoint = ModelCheckpoint (f "results/ { model_name } " + "-loss-{val_loss:.2f}-acc-{val_acc:.2f}. h5" ,
83+ tensorboard = TensorBoard (log_dir = os . path . join ( "logs" , model_name ) )
84+ checkpoint = ModelCheckpoint (os . path . join ( "results" , f" { model_name } " + "-loss-{val_loss:.2f}. h5" ) ,
8685 save_best_only = True ,
8786 verbose = 1 )
8887
0 commit comments