Shortcuts

nas

class trojanvision.models.DARTS(name='darts', model_arch='darts', layers=20, init_channels=36, dropout_p=0.2, auxiliary=False, auxiliary_weight=0.4, genotype=None, model=_DARTS, supernet=False, arch_search=False, use_full_train_set=False, arch_lr=3e-4, arch_weight_decay=1e-3, arch_unrolled=False, primitives=PRIMITIVES, **kwargs)[source]

DARTS-like models used in Neural Architecture Search.

Available model names:
{'darts'}
Parameters:
  • supernet (bool) – Whether to use supernet (mixed operations). Defaults to False.

  • model_arch (str) –

    Genotype name in trojanvision.utils.model_archs.genotypes to use. Defaults to 'darts'.

    • 'amoebanet', 'amoebanet_adapt'

    • 'darts_v1', 'darts_v2'('darts')

    • 'drnas_cifar10'('drnas'), 'drnas_imagenet'

    • 'enas', 'enas_adapt'

    • 'nasnet', 'nasnet_adapt'

    • 'pc_darts_cifar'('pc_darts'), 'pc_darts_image'

    • 'pdarts'

    • 'robust_darts'

    • 'sgas'

    • 'snas_mild', 'snas_adapt'

    • 'random'

    • 'diy_deep', 'diy_noskip', 'diy_deep_noskip'

  • layers (int) – Total number of layers. Defaults to 20.

  • init_channels (int) – out_channel of stem conv layer. Defaults to 36.

  • dropout_p (float) – Dropout probability. Defaults to 0.2.

  • auxiliary (bool) – Whether to use auxiliary classifier. Defaults to False.

  • auxiliary_weight (float) – Loss weight of auxiliary classifier. Defaults to 0.4.

  • arch_search (bool) – Whether to search supernet architecture weight parameters. Defaults to False.

  • use_full_train_set (bool) – Whether to use full training data during architecture search. Defaults to False.

  • arch_lr (float) – Learning rate for architecture optimizer. Defaults to 3e-4

  • arch_weight_decay (float) – Weight decay for architecture optimizer. Defaults to 1e-3.

  • arch_unrolled (bool) – Whether to use one-step unrolled validation loss (darts-v2). Defaults to False.

Variables:

genotype (Genotype) – Genotype of cell architecture.

Note

The implementation of DARTS model is in trojanvision.utils.model_archs.darts

class trojanvision.models.ENAS(name='enas', model=_ENAS, folder_path=None, **kwargs)[source]

This is yet another ENAS implementation based on Microsoft Neural Network Intelligence (NNI) library. You need to first generate 'enas_macro.pt' using NNI library and put it under folder_path.

Warning

It is highly recommended to use trojanvision.models.DARTS with model_arch='enas' instead.

Available model names:
{'enas'}
class trojanvision.models.NATSbench(name='nats_bench', model=_NATSbench, model_index=0, model_seed=777, hp=200, dataset=None, dataset_name=None, nats_path=None, search_space='tss', **kwargs)[source]

NATS-Bench proposed by Xuanyi Dong from University of Technology Sydney.

Available model names:
{'nats_bench'}

Note

There are prerequisites to use the benchmark:

  • pip install nats_bench.

  • git clone https://github.com/D-X-Y/AutoDL-Projects.git and pip install .

  • Extract NATS-tss-v1_0-3ffb9-full to nats_path.

Parameters:
  • model_index (int) – model_index passed to api.get_net_config(). Ranging from 0 -- 15624. Defaults to 0.

  • model_seed (int) – model_seed passed to api.get_net_param(). Choose from [777, 888, 999]. Defaults to 777.

  • hp (int) – Training epochs. hp passed to api.get_net_param(). Choose from [12, 200]. Defaults to 200.

  • nats_path (str) – NATS benchmark file path. It should be set as format like '**/NATS-tss-v1_0-3ffb9-full'

  • search_space (str) – Search space of topology or size. Choose from ['tss', 'sss'].

  • dataset_name (str) – Dataset name. Choose from ['cifar10', 'cifar10-valid', 'cifar100', 'imagenet16-120'].

class trojanvision.models.PNASNet(name='pnasnet', layer='_b', model=_PNASNet, **kwargs)[source]

PNASNet proposed by Chenxi Liu from Johns Hopkins University in ECCV 2018.

Note

The implementation is imported from a third-party github repo. The correctness can’t be guaranteed. It might be better to reimplement according to tensorflow codes: https://github.com/tensorflow/models/blob/master/research/slim/nets/nasnet/pnasnet.py

Available model names:
{'pnasnet', 'pnasnet_a', 'pnasnet_b'}
class trojanvision.models.ProxylessNAS(name='proxylessnas', target_platform='proxyless_cifar', model=_ProxylessNAS, **kwargs)[source]

ProxylessNAS proposed by Han Cai from MIT in ICLR 2019.

Available model names:
{'proxylessnas'}
Parameters:

target_platform (str) – Target platform to load using torch.hub.load. Choose from ['proxyless_cpu', 'proxyless_gpu', 'proxyless_mobile', 'proxyless_mobile_14', 'proxyless_cifar'] Defaults to 'proxyless_cifar'.

Docs

Access comprehensive developer documentation for TrojanZoo

View Docs