get_dl_model_layer_weightsT_get_dl_model_layer_weightsGetDlModelLayerWeightsGetDlModelLayerWeightsget_dl_model_layer_weights (Operator)

Name

get_dl_model_layer_weightsT_get_dl_model_layer_weightsGetDlModelLayerWeightsGetDlModelLayerWeightsget_dl_model_layer_weights — Get the weights (or values) of a Deep Learning model layer.

Signature

get_dl_model_layer_weights( : Weights : DLModelHandle, LayerName, WeightsType : )

Herror T_get_dl_model_layer_weights(Hobject* Weights, const Htuple DLModelHandle, const Htuple LayerName, const Htuple WeightsType)

void GetDlModelLayerWeights(HObject* Weights, const HTuple& DLModelHandle, const HTuple& LayerName, const HTuple& WeightsType)

HImage HDlModel::GetDlModelLayerWeights(const HString& LayerName, const HString& WeightsType) const

HImage HDlModel::GetDlModelLayerWeights(const char* LayerName, const char* WeightsType) const

HImage HDlModel::GetDlModelLayerWeights(const wchar_t* LayerName, const wchar_t* WeightsType) const   ( Windows only)

static void HOperatorSet.GetDlModelLayerWeights(out HObject weights, HTuple DLModelHandle, HTuple layerName, HTuple weightsType)

HImage HDlModel.GetDlModelLayerWeights(string layerName, string weightsType)

def get_dl_model_layer_weights(dlmodel_handle: HHandle, layer_name: str, weights_type: str) -> HObject

Description

The operator get_dl_model_layer_weightsget_dl_model_layer_weightsGetDlModelLayerWeightsGetDlModelLayerWeightsget_dl_model_layer_weights returns in WeightsWeightsWeightsweightsweights the values of a LayerNameLayerNameLayerNamelayerNamelayer_name of the model DLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle.

The parameter WeightsTypeWeightsTypeWeightsTypeweightsTypeweights_type determines which type of layer values are retrieved. The following values are supported for WeightsTypeWeightsTypeWeightsTypeweightsTypeweights_type:

The following tables give an overview, which parameters for WeightsTypeWeightsTypeWeightsTypeweightsTypeweights_type can be set using set_dl_model_layer_weightsset_dl_model_layer_weightsSetDlModelLayerWeightsSetDlModelLayerWeightsset_dl_model_layer_weights and which ones can be retrieved using get_dl_model_layer_weightsget_dl_model_layer_weightsGetDlModelLayerWeightsGetDlModelLayerWeightsget_dl_model_layer_weights.

Layer Parameters set get
'batchnorm_mean'"batchnorm_mean""batchnorm_mean""batchnorm_mean""batchnorm_mean" x x
'batchnorm_mean_avg'"batchnorm_mean_avg""batchnorm_mean_avg""batchnorm_mean_avg""batchnorm_mean_avg" x x
'batchnorm_variance'"batchnorm_variance""batchnorm_variance""batchnorm_variance""batchnorm_variance" x x
'batchnorm_variance_avg'"batchnorm_variance_avg""batchnorm_variance_avg""batchnorm_variance_avg""batchnorm_variance_avg" x x
'bias'"bias""bias""bias""bias" x x
'bias_gradient'"bias_gradient""bias_gradient""bias_gradient""bias_gradient" x
'bias_gradient_norm_l2'"bias_gradient_norm_l2""bias_gradient_norm_l2""bias_gradient_norm_l2""bias_gradient_norm_l2" x
'bias_norm_l2'"bias_norm_l2""bias_norm_l2""bias_norm_l2""bias_norm_l2" x
'bias_update'"bias_update""bias_update""bias_update""bias_update" x
'bias_update_norm_l2'"bias_update_norm_l2""bias_update_norm_l2""bias_update_norm_l2""bias_update_norm_l2" x
'weights'"weights""weights""weights""weights" x x
'weights_gradient'"weights_gradient""weights_gradient""weights_gradient""weights_gradient" x
'weights_gradient_norm_l2'"weights_gradient_norm_l2""weights_gradient_norm_l2""weights_gradient_norm_l2""weights_gradient_norm_l2" x
'weights_norm_l2'"weights_norm_l2""weights_norm_l2""weights_norm_l2""weights_norm_l2" x
'weights_update'"weights_update""weights_update""weights_update""weights_update" x
'weights_update_norm_l2'"weights_update_norm_l2""weights_update_norm_l2""weights_update_norm_l2""weights_update_norm_l2" x

Attention

The operator get_dl_model_layer_weightsget_dl_model_layer_weightsGetDlModelLayerWeightsGetDlModelLayerWeightsget_dl_model_layer_weights is only applicable to self-created networks. For networks delivered by HALCON, the operator returns an empty tuple.

Execution Information

Parameters

WeightsWeightsWeightsweightsweights (output_object)  image(-array) objectHImageHObjectHObjectHobject * (real)

Output weights.

DLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle (input_control)  dl_model HDlModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the deep learning model.

LayerNameLayerNameLayerNamelayerNamelayer_name (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Name of the layer to be queried.

WeightsTypeWeightsTypeWeightsTypeweightsTypeweights_type (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Selected type of layer values to be returned.

Default: 'weights' "weights" "weights" "weights" "weights"

List of values: 'batchnorm_mean'"batchnorm_mean""batchnorm_mean""batchnorm_mean""batchnorm_mean", 'batchnorm_mean_avg'"batchnorm_mean_avg""batchnorm_mean_avg""batchnorm_mean_avg""batchnorm_mean_avg", 'batchnorm_variance'"batchnorm_variance""batchnorm_variance""batchnorm_variance""batchnorm_variance", 'batchnorm_variance_avg'"batchnorm_variance_avg""batchnorm_variance_avg""batchnorm_variance_avg""batchnorm_variance_avg", 'bias'"bias""bias""bias""bias", 'bias_gradient'"bias_gradient""bias_gradient""bias_gradient""bias_gradient", 'bias_gradient_norm_l2'"bias_gradient_norm_l2""bias_gradient_norm_l2""bias_gradient_norm_l2""bias_gradient_norm_l2", 'bias_norm_l2'"bias_norm_l2""bias_norm_l2""bias_norm_l2""bias_norm_l2", 'bias_update'"bias_update""bias_update""bias_update""bias_update", 'bias_update_norm_l2'"bias_update_norm_l2""bias_update_norm_l2""bias_update_norm_l2""bias_update_norm_l2", 'weights'"weights""weights""weights""weights", 'weights_gradient'"weights_gradient""weights_gradient""weights_gradient""weights_gradient", 'weights_gradient_norm_l2'"weights_gradient_norm_l2""weights_gradient_norm_l2""weights_gradient_norm_l2""weights_gradient_norm_l2", 'weights_norm_l2'"weights_norm_l2""weights_norm_l2""weights_norm_l2""weights_norm_l2", 'weights_update'"weights_update""weights_update""weights_update""weights_update", 'weights_update_norm_l2'"weights_update_norm_l2""weights_update_norm_l2""weights_update_norm_l2""weights_update_norm_l2"

Example (HDevelop)

set_system ('seed_rand', 42)
* Create a small model network.
create_dl_layer_input ('input', [InputImageSize[0],InputImageSize[1],1], [],\
                       [], DLGraphNodeInput)
create_dl_layer_convolution (DLGraphNodeInput, 'conv', 3, 1, 1, 2, 1, 'none',\
                             'none', [], [], DLGraphNodeConvolution)
create_dl_layer_activation (DLGraphNodeConvolution, 'relu', 'relu', [], [],\
                            DLGraphNodeActivation)
create_dl_layer_dense (DLGraphNodeActivation, 'dense', 3, [], [],\
                       DLGraphNodeDense)
create_dl_layer_softmax (DLGraphNodeDense, 'softmax', [], [],\
                          DLGraphNodeSoftMax)
create_dl_model (DLGraphNodeSoftMax, DLModelHandle)
*
set_dl_model_param (DLModelHandle, 'type', 'classification')
set_dl_model_param (DLModelHandle, 'batch_size', 1)
set_dl_model_param (DLModelHandle, 'runtime', 'gpu')
set_dl_model_param (DLModelHandle, 'runtime_init', 'immediately')
*
* Train for 5 iterations.
for TrainIterations := 1 to NumTrainIterations by 1
    train_dl_model_batch (DLModelHandle, DLSample, DLTrainResult)
endfor
*
* Get the gradients, weights, and activations.
get_dl_model_layer_gradients (GradientsSoftmax, DLModelHandle, 'softmax')
get_dl_model_layer_gradients (GradientsDense, DLModelHandle, 'dense')
get_dl_model_layer_gradients (GradientsConv, DLModelHandle, 'conv')
*
get_dl_model_layer_weights (WeightsDense, DLModelHandle, 'dense',\
                      'weights_gradient')
get_dl_model_layer_weights (WeightsConv, DLModelHandle, 'conv',\
                      'weights_gradient')
*
get_dl_model_layer_activations (ActivationsDense,  DLModelHandle, 'dense')
get_dl_model_layer_activations (ActivationsConv,  DLModelHandle, 'conv')

Possible Predecessors

create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelcreate_dl_model, train_dl_classifier_batchtrain_dl_classifier_batchTrainDlClassifierBatchTrainDlClassifierBatchtrain_dl_classifier_batch, set_dl_model_layer_weightsset_dl_model_layer_weightsSetDlModelLayerWeightsSetDlModelLayerWeightsset_dl_model_layer_weights

Possible Successors

set_dl_model_layer_weightsset_dl_model_layer_weightsSetDlModelLayerWeightsSetDlModelLayerWeightsset_dl_model_layer_weights

Alternatives

get_dl_model_layer_activationsget_dl_model_layer_activationsGetDlModelLayerActivationsGetDlModelLayerActivationsget_dl_model_layer_activations, get_dl_model_layer_gradientsget_dl_model_layer_gradientsGetDlModelLayerGradientsGetDlModelLayerGradientsget_dl_model_layer_gradients

Module

Foundation. This operator uses dynamic licensing (see the ``Installation Guide''). Which of the following modules is required depends on the specific usage of the operator:
Deep Learning Training