Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc94ac17

Browse files
committed
edited transfer learning tutorial
1 parent62d02cc commitc94ac17

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

‎machine-learning/image-classifier-using-transfer-learning/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# constructs the model
66
model=create_model(input_shape=IMAGE_SHAPE)
77
# load the optimal weights
8-
model.load_weights("results/MobileNetV2_finetune_last5_less_lr-loss-0.45-acc-0.86.h5")
8+
model.load_weights("results/MobileNetV2_finetune_last5-loss-0.66.h5")
99

1010
validation_steps_per_epoch=np.ceil(validation_generator.samples/batch_size)
1111
# print the validation loss & accuracy

‎machine-learning/image-classifier-using-transfer-learning/train.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
21
importtensorflowastf
3-
fromkeras.modelsimportModel
4-
fromkeras.applicationsimportMobileNetV2,ResNet50,InceptionV3# try to use them and see which is better
5-
fromkeras.layersimportDense
6-
fromkeras.callbacksimportModelCheckpoint,TensorBoard
7-
fromkeras.utilsimportget_file
8-
fromkeras.preprocessing.imageimportImageDataGenerator
2+
fromtensorflow.keras.modelsimportModel
3+
fromtensorflow.keras.applicationsimportMobileNetV2,ResNet50,InceptionV3# try to use them and see which is better
4+
fromtensorflow.keras.layersimportDense
5+
fromtensorflow.keras.callbacksimportModelCheckpoint,TensorBoard
6+
fromtensorflow.keras.utilsimportget_file
7+
fromtensorflow.keras.preprocessing.imageimportImageDataGenerator
98
importos
109
importpathlib
1110
importnumpyasnp
@@ -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 usingrmsprop optimizer
67+
# training the model usingadam optimizer
6968
model.compile(loss="categorical_crossentropy",optimizer="adam",metrics=["accuracy"])
7069
returnmodel
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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp