always start from best model
This commit is contained in:
parent
a25e1eb686
commit
070d58f2bf
@ -355,6 +355,7 @@ def parse_args():
|
|||||||
parser.add_argument('--epochs', type=int, default=100)
|
parser.add_argument('--epochs', type=int, default=100)
|
||||||
parser.add_argument('--lr', type=float, default=3e-4)
|
parser.add_argument('--lr', type=float, default=3e-4)
|
||||||
parser.add_argument('--threshold', type=float, default=0.005)
|
parser.add_argument('--threshold', type=float, default=0.005)
|
||||||
|
parser.add_argument('--start_fresh', action='store_true', help='Start training from scratch ignoring saved checkpoints.')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
def random_action():
|
def random_action():
|
||||||
@ -379,7 +380,18 @@ async def main():
|
|||||||
return
|
return
|
||||||
base_tf = "1m"
|
base_tf = "1m"
|
||||||
env = BacktestEnvironment(candles_dict, base_tf, timeframes)
|
env = BacktestEnvironment(candles_dict, base_tf, timeframes)
|
||||||
train_on_historical_data(env, model, device, args)
|
start_epoch = 0
|
||||||
|
if not args.start_fresh:
|
||||||
|
checkpoint = load_best_checkpoint(model)
|
||||||
|
if checkpoint is not None:
|
||||||
|
start_epoch = checkpoint.get("epoch", 0) + 1
|
||||||
|
print(f"Resuming training from epoch {start_epoch}.")
|
||||||
|
else:
|
||||||
|
print("No checkpoint found. Starting training from scratch.")
|
||||||
|
else:
|
||||||
|
print("Starting training from scratch as requested.")
|
||||||
|
|
||||||
|
train_on_historical_data(env, model, device, args, start_epoch=start_epoch)
|
||||||
elif args.mode == 'live':
|
elif args.mode == 'live':
|
||||||
load_best_checkpoint(model)
|
load_best_checkpoint(model)
|
||||||
candles_dict = load_candles_cache(CACHE_FILE)
|
candles_dict = load_candles_cache(CACHE_FILE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user