0

Original example code is:

 @ag.args(
  lr=ag.space.Real(1e-3, 1e-2, log=True),
  wd=ag.space.Real(1e-3, 1e-2),
  epochs=10)
def train_fn(args, reporter):
    print('lr: {}, wd: {}'.format(args.lr, args.wd))
    for e in range(args.epochs):
        dummy_accuracy = 1 - np.power(1.8, -np.random.uniform(e, 2*e))
        reporter(epoch=e+1, accuracy=dummy_accuracy, lr=args.lr, wd=args.wd)
scheduler = ag.scheduler.HyperbandScheduler(
    train_fn,
    resource={'num_cpus': 2, 'num_gpus': 0},
    num_trials=100,
    reward_attr='accuracy',
    time_attr='epoch',
    grace_period=1,
    reduction_factor=3,
    type='stopping')
scheduler.run()
scheduler.join_jobs()

I want to use like this:

config = {
    "lr" : ag.space.Real(1e-3, 1e-2, log=True),
    "wd" : ag.space.Real(1e-3, 1e-2),
    "epochs" : 10,
}
@ag.args(config)
def train_fn(args, reporter):
    print('lr: {}, wd: {}'.format(args.lr, args.wd))
    for e in range(args.epochs):
        dummy_accuracy = 1 - np.power(1.8, -np.random.uniform(e, 2*e))
        reporter(epoch=e+1, accuracy=dummy_accuracy, lr=args.lr, wd=args.wd)

@ag.args argument type is dictionary in auto gluon document, how can I use that?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 1
    Does this answer your question? [Passing a dictionary to a function as keyword parameters](https://stackoverflow.com/questions/334655/passing-a-dictionary-to-a-function-as-keyword-parameters) – jonrsharpe Jul 15 '20 at 07:25
  • thanks your comment, I don't understand exactly but solve that! – user9041996 Jul 15 '20 at 07:35

0 Answers0