mirror of
https://github.com/AntoineHX/smart_augmentation.git
synced 2025-05-04 04:00:46 +02:00
Changement permission fichiers + Simplification utilisation Augmented_dataset
This commit is contained in:
parent
adaac437b6
commit
b26fbcd2a2
619 changed files with 41 additions and 13049 deletions
36
higher/test_dataug.py
Normal file → Executable file
36
higher/test_dataug.py
Normal file → Executable file
|
@ -66,11 +66,11 @@ if __name__ == "__main__":
|
|||
|
||||
tasks={
|
||||
#'classic',
|
||||
'aug_dataset',
|
||||
#'aug_model'
|
||||
#'aug_dataset',
|
||||
'aug_model'
|
||||
}
|
||||
n_inner_iter = 1
|
||||
epochs = 100
|
||||
epochs = 200
|
||||
dataug_epoch_start=0
|
||||
|
||||
|
||||
|
@ -83,13 +83,14 @@ if __name__ == "__main__":
|
|||
#model.augment(mode=False)
|
||||
|
||||
print(str(model), 'on', device_name)
|
||||
log= train_classic(model=model, epochs=epochs)
|
||||
log= train_classic(model=model, epochs=epochs, print_freq=10)
|
||||
#log= train_classic_higher(model=model, epochs=epochs)
|
||||
|
||||
exec_time=time.process_time() - t0
|
||||
####
|
||||
print('-'*9)
|
||||
times = [x["time"] for x in log]
|
||||
out = {"Accuracy": max([x["acc"] for x in log]), "Time": (np.mean(times),np.std(times)), "Device": device_name, "Log": log}
|
||||
out = {"Accuracy": max([x["acc"] for x in log]), "Time": (np.mean(times),np.std(times), exec_time), "Device": device_name, "Log": log}
|
||||
print(str(model),": acc", out["Accuracy"], "in:", out["Time"][0], "+/-", out["Time"][1])
|
||||
filename = "{}-{} epochs".format(str(model),epochs)
|
||||
with open("res/log/%s.json" % filename, "w+") as f:
|
||||
|
@ -98,29 +99,37 @@ if __name__ == "__main__":
|
|||
|
||||
plot_res(log, fig_name="res/"+filename)
|
||||
|
||||
print('Execution Time : %.00f '%(time.process_time() - t0))
|
||||
print('Execution Time : %.00f '%(exec_time))
|
||||
print('-'*9)
|
||||
|
||||
|
||||
#### Augmented Dataset ####
|
||||
if 'aug_dataset' in tasks:
|
||||
|
||||
xs, ys = next(iter(dl_train))
|
||||
viz_sample_data(imgs=xs, labels=ys, fig_name='samples/data_sample_{}'.format(str(data_train_aug)))
|
||||
t0 = time.process_time()
|
||||
|
||||
data_train_aug = AugmentedDataset("./data", train=True, download=download_data, transform=transform, subset=(0,int(len(data_train)/2)))
|
||||
data_train_aug.augement_data(aug_copy=10)
|
||||
print(data_train_aug)
|
||||
dl_train = torch.utils.data.DataLoader(data_train_aug, batch_size=BATCH_SIZE, shuffle=True)
|
||||
|
||||
#xs, ys = next(iter(dl_train))
|
||||
#viz_sample_data(imgs=xs, labels=ys, fig_name='samples/data_sample_{}'.format(str(data_train_aug)))
|
||||
|
||||
model = LeNet(3,10).to(device)
|
||||
#model = WideResNet(num_classes=10, wrn_size=16).to(device)
|
||||
#model = Augmented_model(Data_augV3(mix_dist=0.0), LeNet(3,10)).to(device)
|
||||
#model.augment(mode=False)
|
||||
|
||||
print(str(model), 'on', device_name)
|
||||
log= train_classic(model=model, epochs=epochs)
|
||||
log= train_classic(model=model, epochs=epochs, print_freq=10)
|
||||
#log= train_classic_higher(model=model, epochs=epochs)
|
||||
|
||||
exec_time=time.process_time() - t0
|
||||
####
|
||||
print('-'*9)
|
||||
times = [x["time"] for x in log]
|
||||
out = {"Accuracy": max([x["acc"] for x in log]), "Time": (np.mean(times),np.std(times)), "Device": device_name, "Log": log}
|
||||
out = {"Accuracy": max([x["acc"] for x in log]), "Time": (np.mean(times),np.std(times), exec_time), "Device": device_name, "Log": log}
|
||||
print(str(model),": acc", out["Accuracy"], "in:", out["Time"][0], "+/-", out["Time"][1])
|
||||
filename = "{}-{}-{} epochs".format(str(data_train_aug),str(model),epochs)
|
||||
with open("res/log/%s.json" % filename, "w+") as f:
|
||||
|
@ -129,7 +138,7 @@ if __name__ == "__main__":
|
|||
|
||||
plot_res(log, fig_name="res/"+filename)
|
||||
|
||||
print('Execution Time : %.00f '%(time.process_time() - t0))
|
||||
print('Execution Time : %.00f '%(exec_time))
|
||||
print('-'*9)
|
||||
|
||||
|
||||
|
@ -147,10 +156,11 @@ if __name__ == "__main__":
|
|||
#run_simple_dataug(inner_it=n_inner_iter, epochs=epochs)
|
||||
log= run_dist_dataugV2(model=aug_model, epochs=epochs, inner_it=n_inner_iter, dataug_epoch_start=dataug_epoch_start, print_freq=10, loss_patience=None)
|
||||
|
||||
exec_time=time.process_time() - t0
|
||||
####
|
||||
print('-'*9)
|
||||
times = [x["time"] for x in log]
|
||||
out = {"Accuracy": max([x["acc"] for x in log]), "Time": (np.mean(times),np.std(times)), "Device": device_name, "Param_names": aug_model.TF_names(), "Log": log}
|
||||
out = {"Accuracy": max([x["acc"] for x in log]), "Time": (np.mean(times),np.std(times), exec_time), "Device": device_name, "Param_names": aug_model.TF_names(), "Log": log}
|
||||
print(str(aug_model),": acc", out["Accuracy"], "in:", out["Time"][0], "+/-", out["Time"][1])
|
||||
filename = "{}-{} epochs (dataug:{})- {} in_it".format(str(aug_model),epochs,dataug_epoch_start,n_inner_iter)
|
||||
with open("res/log/%s.json" % filename, "w+") as f:
|
||||
|
@ -159,5 +169,5 @@ if __name__ == "__main__":
|
|||
|
||||
plot_resV2(log, fig_name="res/"+filename, param_names=tf_names)
|
||||
|
||||
print('Execution Time : %.00f '%(time.process_time() - t0))
|
||||
print('Execution Time : %.00f '%(exec_time))
|
||||
print('-'*9)
|
Loading…
Add table
Add a link
Reference in a new issue