sax.nn.io module#

SAX Neural Network I/O Utilities

load_nn_weights_json(path)[source]#

Load json weights from given path

Parameters:

path (str) –

Return type:

Dict[str, ComplexArrayND]

save_nn_weights_json(weights, path)[source]#

Save json weights to given path

Parameters:
  • weights (Dict[str, ComplexArrayND]) –

  • path (str) –

get_available_sizes(dirpath, prefix, input_names, output_names)[source]#

Get all available json weight hidden sizes given filename parameters

> Note: this function does NOT return the input size and the output size

of the neural network. ONLY the hidden sizes are reported. The input and output sizes can easily be derived from input_names (after preprocessing) and output_names.

Parameters:
  • dirpath (str) –

  • prefix (str) –

  • input_names (Tuple[str, ...]) –

  • output_names (Tuple[str, ...]) –

Return type:

List[Tuple[int, …]]

get_dense_weights_path(*sizes, input_names=None, output_names=None, dirpath='weights', prefix='dense', preprocess=<function preprocess>)[source]#

Create the SAX conventional path for a given weight dictionary

Parameters:
  • sizes (int) –

  • input_names (Optional[Tuple[str, ...]]) –

  • output_names (Optional[Tuple[str, ...]]) –

  • dirpath (str) –

  • prefix (str) –

get_norm_path(*shape, input_names=None, output_names=None, dirpath='norms', prefix='norm', preprocess=<function preprocess>)[source]#

Create the SAX conventional path for the normalization constants

Parameters:
  • shape (int) –

  • input_names (Optional[Tuple[str, ...]]) –

  • output_names (Optional[Tuple[str, ...]]) –

  • dirpath (str) –

  • prefix (str) –

load_nn_dense(*sizes, input_names=None, output_names=None, weightprefix='dense', weightdirpath='weights', normdirpath='norms', normprefix='norm', preprocess=<function preprocess>)[source]#

Load a pre-trained dense model

Parameters:
  • sizes (int) –

  • input_names (Optional[Tuple[str, ...]]) –

  • output_names (Optional[Tuple[str, ...]]) –

Return type:

Callable