Helpers for importing individual layers

You're likely to want to import parameter values from your trained neural networks from outside of Julia. get_conv_params and get_matrix_params are helper functions enabling you to import individual layers.

Index

Public Interface

MIPVerify.get_conv_paramsMethod
get_conv_params(
    param_dict,
    layer_name,
    expected_size;
    matrix_name,
    bias_name,
    expected_stride,
    padding
)

Helper function to import the parameters for a convolution layer from param_dict as a Conv2d object.

The default format for the key is 'layer_name/weight' and 'layer_name/bias'; you can customize this by passing in the named arguments matrix_name and bias_name respectively. The expected parameter names will then be 'layer_name/matrix_name' and 'layer_name/bias_name'

Arguments

  • param_dict::Dict{String}: Dictionary mapping parameter names to array of weights / biases.
  • layer_name::String: Identifies parameter in dictionary.
  • expected_size::NTuple{4, Int}: Tuple of length 4 corresponding to the expected size of the weights of the layer.
source
MIPVerify.get_matrix_paramsMethod
get_matrix_params(
    param_dict,
    layer_name,
    expected_size;
    matrix_name,
    bias_name
)

Helper function to import the parameters for a layer carrying out matrix multiplication (e.g. fully connected layer / softmax layer) from param_dict as a Linear object.

The default format for the key is 'layer_name/weight' and 'layer_name/bias'; you can customize this by passing in the named arguments matrix_name and bias_name respectively. The expected parameter names will then be 'layer_name/matrix_name' and 'layer_name/bias_name'

Arguments

  • param_dict::Dict{String}: Dictionary mapping parameter names to array of weights / biases.
  • layer_name::String: Identifies parameter in dictionary.
  • expected_size::NTuple{2, Int}: Tuple of length 2 corresponding to the expected size of the weights of the layer.
source

Internal