Skip to content

Commit

Permalink
add fitness tracking, STILL working on it
Browse files Browse the repository at this point in the history
  • Loading branch information
Lechtr committed Apr 1, 2021
1 parent 1c13688 commit 3143b28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,4 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
evolve.txt
21 changes: 15 additions & 6 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,28 +404,35 @@ def train(hyp, opt, device, tb_writer=None):
os.system('gsutil cp %s gs://%s/results/results%s.txt' % (results_file, opt.bucket, opt.name))

# Log
fi = fitness(np.array(results).reshape(1, -1)) # weighted combination of [P, R, mAP@.5, mAP@.5-.95]
tags = ['train/box_loss', 'train/obj_loss', 'train/cls_loss', # train loss
'metrics/precision', 'metrics/recall', 'metrics/mAP_0.5', 'metrics/mAP_0.5:0.95',
'val/box_loss', 'val/obj_loss', 'val/cls_loss', # val loss
'x/lr0', 'x/lr1', 'x/lr2'] # params
for x, tag in zip(list(mloss[:-1]) + list(results) + lr, tags):
'x/lr0', 'x/lr1', 'x/lr2',
# 'metrics/fitness'
] # params
for x, tag in zip(list(mloss[:-1]) + list(results) + lr, tags):# + list(fi), tags):
if tb_writer:
tb_writer.add_scalar(tag, x, epoch) # tensorboard
if wandb_logger.wandb:
wandb_logger.log({tag: x}) # W&B

# Update best mAP
fi = fitness(np.array(results).reshape(1, -1)) # weighted combination of [P, R, mAP@.5, mAP@.5-.95]
# fi = fitness(np.array(results).reshape(1, -1)) # weighted combination of [P, R, mAP@.5, mAP@.5-.95]
if fi > best_fitness:
best_fitness = fi
wandb_logger.end_epoch(best_result=best_fitness == fi)
# wandb_logger.log({"metrics/fitness": str(fi)}) # W&B



### Ray Tune report Metric
print("fitness: ")
print(fi)
tune.report(fitness=fi)
if(opt.raytune):
print("fitness: ")
print(fi)
tune.report(fitness=fi)





Expand Down Expand Up @@ -495,6 +502,8 @@ def train(hyp, opt, device, tb_writer=None):
return results




''' Add Raytune-Hyp-Opt functionality'''
global_hyp = None
global_opt = None
Expand Down

0 comments on commit 3143b28

Please sign in to comment.