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
Train acc | Val acc | Time per epoch | |
---|---|---|---|
92.9% | 96.0% | 79 sec |
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
Train acc | Val acc | Time per epoch | |
---|---|---|---|
96.2% | 95.3% | 20 sec |
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
Train acc | Val acc | Time per epoch | |
---|---|---|---|
85.0% | 65.0% | 80 sec |
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
Train acc | Val acc | Time per epoch | |
---|---|---|---|
88.0% | 72.0% | 33 sec |
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
Train acc | Val acc | Time per epoch | |
---|---|---|---|
88.0% | 67.3% | 32 sec |
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
model.load_weights(ckpt_dir) | |
for inputs in test_gen: | |
outputs = model(inputs, training=False) | |
break |
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
#load model weights | |
model.load_state_dict(torch.load(ckpt_dir)) | |
for inputs, targets in test_gen: | |
# use GPU if available | |
inputs = inputs.to(device) | |
inputs = inputs.float() | |
outputs = model(inputs) | |
break |
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
learning_rate = 0.0001 | |
#get mobilenet | |
model = torchvision.models.mobilenet_v2(pretrained=True) | |
# freeze the feature extraction convolutional layers | |
for param in model.parameters(): | |
param.requires_grad = False | |
# define a classification layer |
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
from torch.utils.tensorboard import SummaryWriter | |
# Setup tensorboard | |
file_writer = SummaryWriter(log_dir=log_dir + '/metrics') | |
best_val_acc = 0 # for model check pointing | |
# Epoch loop | |
for epoch in range(1, num_epoch + 1): | |
start_time = timer() | |
# Reset metrics | |
train_loss = 0.0 |
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
learning_rate = 0.0001 | |
# get just the feature extraction layers of mobilenet | |
base_model = tf.keras.applications.MobileNetV2( | |
include_top=False, weights='imagenet', input_shape=(im_size, im_size, 3)) | |
# freeze the feature extractor convolutional layers | |
base_model.trainable = False | |
# define a classification layer on top | |
global_average_layer = tf.keras.layers.GlobalAveragePooling2D() |
NewerOlder