|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Most common few-shot eval configuration.""" |
|
|
|
import ml_collections as mlc |
|
|
|
|
|
def get_fewshot_lsr(target_resolution=224, resize_resolution=256, |
|
runlocal=False, **kw): |
|
"""Returns a standard-ish fewshot eval configuration.""" |
|
kw.setdefault('representation_layer', 'pre_logits') |
|
kw.setdefault('shots', (1, 5, 10, 25)) |
|
kw.setdefault('l2_reg', 2.0 ** 10) |
|
kw.setdefault('num_seeds', 3) |
|
kw.setdefault('prefix', '') |
|
|
|
|
|
if not any(f'log_{x}' in kw for x in ['steps', 'percent', 'examples', 'epochs']): |
|
kw['log_steps'] = 25_000 |
|
|
|
config = mlc.ConfigDict(kw) |
|
config.type = 'fewshot_lsr' |
|
config.datasets = { |
|
'caltech': ('caltech101', 'train', 'test'), |
|
'cars': ('cars196:2.1.0', 'train', 'test'), |
|
'cifar100': ('cifar100', 'train', 'test'), |
|
'dtd': ('dtd', 'train', 'test'), |
|
|
|
|
|
|
|
'pets': ('oxford_iiit_pet', 'train', 'test'), |
|
'uc_merced': ('uc_merced', 'train[:1000]', 'train[1000:]'), |
|
} if not runlocal else { |
|
'pets': ('oxford_iiit_pet', 'train', 'test'), |
|
} |
|
config.pp_train = (f'decode|resize({resize_resolution})|' |
|
f'central_crop({target_resolution})|' |
|
f'value_range(-1,1)|keep("image", "label")') |
|
config.pp_eval = (f'decode|resize({resize_resolution})|' |
|
f'central_crop({target_resolution})|' |
|
f'value_range(-1,1)|keep("image", "label")') |
|
config.display_first = [('imagenet', 10)] if not runlocal else [('pets', 10)] |
|
|
|
return config |
|
|