# paddleslim.nas.one_shot package

class `paddleslim.nas.one_shot.``OneShotSuperNet`(name_scope)

  Bases: `paddle.fluid.dygraph.layers.Layer`

  The base class of super net used in one-shot searching strategy. A super net is a dygraph layer.

  Parameters: | name_scope (str) – The name scope of super net.

  `forward`(input, tokens=None)

    Defines the computation performed at every call.

    Parameters:

    - input (variable) – The input of super net.
    - tokens (list) – The tokens used to generate a sub-network. None means computing in super net training mode. Otherwise, it will execute the sub-network generated by tokens. The tokens should be set in searching stage and final training stage. Default: None.

    Returns: | The output of super net.
    Return type: | Varaible

  `init_tokens`()

    Get init tokens in search space.

    Returns: | The init tokens which is a list of integer.
    Return type: | lis<int>t

  `range_table`()

    Get range table of current search space.

    Returns:

    The maximum value and minimum value in each position of tokens
      with format (min_values, max_values). The min_values is a list of integers indicating the minimum values while max_values indicating the maximum values.

    Return type: | range_table(tuple)

`paddleslim.nas.one_shot.``OneShotSearch`(model, eval_func, strategy='sa', search_steps=100)

  Search a best tokens which represents a sub-network.

  Parameters:

  - model (fluid.dygraph.Layer) – A dynamic graph module whose sub-modules should contain one instance of OneShotSuperNet at least.
  - eval_func (function) – A callback function which accept model and tokens as arguments.
  - strategy (str) – The name of strategy used to search. Default: ‘sa’.
  - search_steps (int) – The total steps for searching.

  Returns: | The best tokens searched.
  Return type: | list<int>

class `paddleslim.nas.one_shot.``SuperMnasnet`(name_scope, input_channels=3, out_channels=1280, repeat_times=[6, 6, 6, 6, 6, 6], stride=[1, 1, 1, 1, 2, 1], channels=[16, 24, 40, 80, 96, 192, 320], use_auxhead=False)

  Bases: `paddleslim.nas.one_shot.one_shot_nas.OneShotSuperNet`

  `get_flops`(input, output, op)
  `init_tokens`()
  `range_table`()

## Submodules

## paddleslim.nas.one_shot.one_shot_nas module

class `paddleslim.nas.one_shot.one_shot_nas.``OneShotSuperNet`(name_scope)

  Bases: `paddle.fluid.dygraph.layers.Layer`

  The base class of super net used in one-shot searching strategy. A super net is a dygraph layer.

  Parameters: | name_scope (str) – The name scope of super net.

  `forward`(input, tokens=None)

    Defines the computation performed at every call.

    Parameters:

    - input (variable) – The input of super net.
    - tokens (list) – The tokens used to generate a sub-network. None means computing in super net training mode. Otherwise, it will execute the sub-network generated by tokens. The tokens should be set in searching stage and final training stage. Default: None.

    Returns: | The output of super net.
    Return type: | Varaible

  `init_tokens`()

    Get init tokens in search space.

    Returns: | The init tokens which is a list of integer.
    Return type: | lis<int>t

  `range_table`()

    Get range table of current search space.

    Returns:

    The maximum value and minimum value in each position of tokens
      with format (min_values, max_values). The min_values is a list of integers indicating the minimum values while max_values indicating the maximum values.

    Return type: | range_table(tuple)

`paddleslim.nas.one_shot.one_shot_nas.``OneShotSearch`(model, eval_func, strategy='sa', search_steps=100)

  Search a best tokens which represents a sub-network.

  Parameters:

  - model (fluid.dygraph.Layer) – A dynamic graph module whose sub-modules should contain one instance of OneShotSuperNet at least.
  - eval_func (function) – A callback function which accept model and tokens as arguments.
  - strategy (str) – The name of strategy used to search. Default: ‘sa’.
  - search_steps (int) – The total steps for searching.

  Returns: | The best tokens searched.
  Return type: | list<int>

## paddleslim.nas.one_shot.super_mnasnet module

class `paddleslim.nas.one_shot.super_mnasnet.``SuperMnasnet`(name_scope, input_channels=3, out_channels=1280, repeat_times=[6, 6, 6, 6, 6, 6], stride=[1, 1, 1, 1, 2, 1], channels=[16, 24, 40, 80, 96, 192, 320], use_auxhead=False)

  Bases: `paddleslim.nas.one_shot.one_shot_nas.OneShotSuperNet`

  `get_flops`(input, output, op)
  `init_tokens`()
  `range_table`()