Skip to content

Commit

Permalink
Changed Optimizer to Alpha ultralytics#10
Browse files Browse the repository at this point in the history
  • Loading branch information
manole-alexandru committed Mar 28, 2023
1 parent 72c425a commit 2b5cc45
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion data/hyps/hyp.scratch-high.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# python train.py --batch 32 --cfg yolov5m6.yaml --weights '' --data coco.yaml --img 1280 --epochs 300
# See tutorials for hyperparameter evolution https://github.com/ultralytics/yolov5#tutorials

lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3)
lr0: 0.003 # initial learning rate (SGD=1E-2, Adam=1E-3)
lrf: 0.1 # final OneCycleLR learning rate (lr0 * lrf)
momentum: 0.937 # SGD momentum/Adam beta1
weight_decay: 0.0005 # optimizer weight decay 5e-4
Expand Down
4 changes: 2 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def parse_opt(known=False):
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
parser.add_argument('--multi-scale', action='store_true', help='vary img-size +/- 50%%')
parser.add_argument('--single-cls', action='store_true', help='train multi-class data as single-class')
parser.add_argument('--optimizer', type=str, choices=['SGD', 'Adam', 'AdamW'], default='SGD', help='optimizer')
parser.add_argument('--optimizer', type=str, choices=['SGD', 'Adam', 'AdamW'], default='Adam', help='optimizer')
parser.add_argument('--sync-bn', action='store_true', help='use SyncBatchNorm, only available in DDP mode')
parser.add_argument('--workers', type=int, default=8, help='max dataloader workers (per RANK in DDP mode)')
parser.add_argument('--project', default=ROOT / 'runs/train', help='save to project/name')
Expand All @@ -514,7 +514,7 @@ def parse_opt(known=False):


def main(opt, callbacks=Callbacks()):
print('\n---------- VERSION:', '#0009', '----------\n')
print('\n---------- VERSION:', '#0010', '----------\n')
# Checks
if RANK in {-1, 0}:
print_args(vars(opt))
Expand Down
2 changes: 1 addition & 1 deletion utils/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def forward(self, pred, true):
else: # 'none'
return loss

def weighted_bce(y_pred, y_true, BETA=2):
def weighted_bce(y_pred, y_true, BETA=40):
weights = (y_true * (BETA - 1)) + 1
bce = nn.BCEWithLogitsLoss(reduction='none')(y_pred, y_true)
wbce = torch.mean(bce * weights)
Expand Down
2 changes: 1 addition & 1 deletion val.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def run(
# Print results per class
if (verbose or (nc < 50 and not training)) and nc > 1 and len(stats):
for i, c in enumerate(ap_class):
LOGGER.info(pf % (names[c], seen, nt[c], p[i], r[i], ap50[i], ap[i], iou))
LOGGER.info(pf % (names[c], seen, nt[c], p[i], r[i], ap50[i], ap[i], iou, rail_iou))

# Print speeds
t = tuple(x.t / seen * 1E3 for x in dt) # speeds per image
Expand Down

0 comments on commit 2b5cc45

Please sign in to comment.