1
-
2
1
import 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
9
8
import os
10
9
import pathlib
11
10
import numpy as np
@@ -65,7 +64,7 @@ def create_model(input_shape):
65
64
# print the summary of the model architecture
66
65
model .summary ()
67
66
68
- # training the model using rmsprop optimizer
67
+ # training the model using adam optimizer
69
68
model .compile (loss = "categorical_crossentropy" , optimizer = "adam" , metrics = ["accuracy" ])
70
69
return model
71
70
@@ -81,8 +80,8 @@ def create_model(input_shape):
81
80
model_name = "MobileNetV2_finetune_last5"
82
81
83
82
# 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" ) ,
86
85
save_best_only = True ,
87
86
verbose = 1 )
88
87
0 commit comments