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
learn.unfreeze() | |
learn.fit(0.01, 3, wds=wd) |
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
log_preds,_ = learn.TTA(n_aug=20, is_test=True) | |
preds = np.mean(np.exp(log_preds),0) | |
accuracy_np(preds, y_true) |
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
log_preds,y = learn.predict_with_targs() | |
preds = np.exp(log_preds) | |
pred_labels = np.argmax(preds, axis=1) | |
results = ImageModelResults(data.val_ds, log_preds) | |
results.plot_most_incorrect(1) |
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
learn.unfreeze() | |
lr=np.array([1e-4,1e-3,1e-2]) | |
learn.fit(lr, 5, cycle_len=1, cycle_mult=2) |
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
learn.fit(lr, 4, cycle_len=1, cycle_mult=2, wds=wd) |
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
wd = 5e-4 | |
learn.fit(0.01, 1, wds=wd) |
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
arch = resnet34 | |
learn = ConvLearner.pretrained(arch, data, precompute=False) |
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
def plot_loss_change(sched, sma=1, n_skip=20, y_lim=(-0.01,0.01)): | |
""" | |
Plots rate of change of the loss function. | |
Parameters: | |
sched - learning rate scheduler, an instance of LR_Finder class. | |
sma - number of batches for simple moving average to smooth out the curve. | |
n_skip - number of batches to skip on the left. | |
y_lim - limits for the y axis. | |
""" | |
derivatives = [0] * (sma + 1) |
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
sz = 96 | |
# Look at examples of image augmentation | |
def get_augs(): | |
x,_ = next(iter(data.aug_dl)) | |
return data.trn_ds.denorm(x)[1] | |
aug_tfms = [RandomRotate(20), RandomLighting(0.8, 0.8)] | |
tfms = tfms_from_model(arch, sz, aug_tfms=aug_tfms, max_zoom=1.2) | |
data = ImageClassifierData.from_paths(path, tfms=tfms, test_name='test') |
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
# learn is an instance of Learner class or one of derived classes like ConvLearner | |
learn.lr_find() | |
learn.sched.plot_lr() |
NewerOlder