get_dl_model_layer_weights T_get_dl_model_layer_weights GetDlModelLayerWeights GetDlModelLayerWeights get_dl_model_layer_weights (Operator)
Name
get_dl_model_layer_weights T_get_dl_model_layer_weights GetDlModelLayerWeights GetDlModelLayerWeights get_dl_model_layer_weights
— Get the weights (or values) of a Deep Learning model layer.
Signature
Description
The operator get_dl_model_layer_weights get_dl_model_layer_weights GetDlModelLayerWeights GetDlModelLayerWeights GetDlModelLayerWeights get_dl_model_layer_weights
returns in Weights Weights Weights Weights weights weights
the values of a LayerName LayerName LayerName LayerName layerName layer_name
of the model DLModelHandle DLModelHandle DLModelHandle DLModelHandle DLModelHandle dlmodel_handle
.
The parameter WeightsType WeightsType WeightsType WeightsType weightsType weights_type
determines which type of layer values are
retrieved.
The following values are supported for WeightsType WeightsType WeightsType WeightsType weightsType weights_type
:
'batchnorm_mean' "batchnorm_mean" "batchnorm_mean" "batchnorm_mean" "batchnorm_mean" "batchnorm_mean" : Batch-wise calculated mean values to
normalize the inputs. For further information, please refer to
create_dl_layer_batch_normalization create_dl_layer_batch_normalization CreateDlLayerBatchNormalization CreateDlLayerBatchNormalization CreateDlLayerBatchNormalization create_dl_layer_batch_normalization
.
Restriction: This value is only supported if the layer is of type
'batchnorm' "batchnorm" "batchnorm" "batchnorm" "batchnorm" "batchnorm" .
'batchnorm_mean_avg' "batchnorm_mean_avg" "batchnorm_mean_avg" "batchnorm_mean_avg" "batchnorm_mean_avg" "batchnorm_mean_avg" : Average of the batch-wise calculated
mean values to normalize the inputs. For further information, please refer
to create_dl_layer_batch_normalization create_dl_layer_batch_normalization CreateDlLayerBatchNormalization CreateDlLayerBatchNormalization CreateDlLayerBatchNormalization create_dl_layer_batch_normalization
.
Restriction: This value is only supported if the layer is of type
'batchnorm' "batchnorm" "batchnorm" "batchnorm" "batchnorm" "batchnorm" .
'batchnorm_variance' "batchnorm_variance" "batchnorm_variance" "batchnorm_variance" "batchnorm_variance" "batchnorm_variance" : Batch-wise calculated variance values to
normalize the inputs. For further information, please refer to
create_dl_layer_batch_normalization create_dl_layer_batch_normalization CreateDlLayerBatchNormalization CreateDlLayerBatchNormalization CreateDlLayerBatchNormalization create_dl_layer_batch_normalization
.
Restriction: This value is only supported if the layer is of type
'batchnorm' "batchnorm" "batchnorm" "batchnorm" "batchnorm" "batchnorm" .
'batchnorm_variance_avg' "batchnorm_variance_avg" "batchnorm_variance_avg" "batchnorm_variance_avg" "batchnorm_variance_avg" "batchnorm_variance_avg" : Average of the batch-wise calculated
variance values to normalize the inputs. For further information, please
refer to create_dl_layer_batch_normalization create_dl_layer_batch_normalization CreateDlLayerBatchNormalization CreateDlLayerBatchNormalization CreateDlLayerBatchNormalization create_dl_layer_batch_normalization
.
Restriction: This value is only supported if the layer is of type
'batchnorm' "batchnorm" "batchnorm" "batchnorm" "batchnorm" "batchnorm" .
'bias' "bias" "bias" "bias" "bias" "bias" : Biases of the layer.
'bias_gradient' "bias_gradient" "bias_gradient" "bias_gradient" "bias_gradient" "bias_gradient" : Gradients of the biases of the layer.
'bias_gradient_norm_l2' "bias_gradient_norm_l2" "bias_gradient_norm_l2" "bias_gradient_norm_l2" "bias_gradient_norm_l2" "bias_gradient_norm_l2" : Gradients of the biases of the
layer in terms of L2 norm.
'bias_norm_l2' "bias_norm_l2" "bias_norm_l2" "bias_norm_l2" "bias_norm_l2" "bias_norm_l2" : Biases of the layer in terms of L2 norm.
'bias_update' "bias_update" "bias_update" "bias_update" "bias_update" "bias_update" : Update of the biases of the layer.
This is used in e.g., a solver which uses the last update.
'bias_update_norm_l2' "bias_update_norm_l2" "bias_update_norm_l2" "bias_update_norm_l2" "bias_update_norm_l2" "bias_update_norm_l2" : Update of the biases of the layer
in terms of L2 norm.
This is used in a solver which uses the last update.
'weights' "weights" "weights" "weights" "weights" "weights" : Weights of the layer.
'weights_gradient' "weights_gradient" "weights_gradient" "weights_gradient" "weights_gradient" "weights_gradient" : Gradients of the weights of the layer.
'weights_gradient_norm_l2' "weights_gradient_norm_l2" "weights_gradient_norm_l2" "weights_gradient_norm_l2" "weights_gradient_norm_l2" "weights_gradient_norm_l2" : Gradients of the weights of the
layer in terms of L2 norm.
'weights_norm_l2' "weights_norm_l2" "weights_norm_l2" "weights_norm_l2" "weights_norm_l2" "weights_norm_l2" : Weights of the layer in terms of L2 norm.
'weights_update' "weights_update" "weights_update" "weights_update" "weights_update" "weights_update" : Update of the weights of the layer.
This is used in a solver which uses the last update.
'weights_update_norm_l2' "weights_update_norm_l2" "weights_update_norm_l2" "weights_update_norm_l2" "weights_update_norm_l2" "weights_update_norm_l2" : Update of the weights of the layer
in terms of L2 norm.
This is used in a solver which uses the last update.
The following tables give an overview, which parameters for WeightsType WeightsType WeightsType WeightsType weightsType weights_type
can be set using set_dl_model_layer_weights set_dl_model_layer_weights SetDlModelLayerWeights SetDlModelLayerWeights SetDlModelLayerWeights set_dl_model_layer_weights
and which ones can be retrieved
using get_dl_model_layer_weights get_dl_model_layer_weights GetDlModelLayerWeights GetDlModelLayerWeights GetDlModelLayerWeights get_dl_model_layer_weights
.
Layer Parameters
set
get
'batchnorm_mean' "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_mean_avg"
'batchnorm_variance' "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" "batchnorm_variance_avg"
'bias' "bias" "bias" "bias" "bias" "bias"
'bias_gradient' "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_gradient_norm_l2"
'bias_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"
'bias_update_norm_l2' "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"
'weights_gradient' "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_gradient_norm_l2"
'weights_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"
'weights_update_norm_l2' "weights_update_norm_l2" "weights_update_norm_l2" "weights_update_norm_l2" "weights_update_norm_l2" "weights_update_norm_l2"
Attention
The operator get_dl_model_layer_weights get_dl_model_layer_weights GetDlModelLayerWeights GetDlModelLayerWeights GetDlModelLayerWeights get_dl_model_layer_weights
is only applicable to self-created
networks. For networks delivered by HALCON, the operator returns an
empty tuple.
Execution Information
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
Multithreading scope: global (may be called from any thread).
Processed without parallelization.
Parameters
Weights Weights Weights Weights weights weights
(output_object) image(-array) →
object HImage HObject HImage Hobject * (real)
Output weights.
DLModelHandle DLModelHandle DLModelHandle DLModelHandle DLModelHandle dlmodel_handle
(input_control) dl_model →
HDlModel , HTuple HHandle HTuple Htuple (handle) (IntPtr ) (HHandle ) (handle )
Handle of the deep learning model.
LayerName LayerName LayerName LayerName layerName layer_name
(input_control) string →
HTuple str HTuple Htuple (string) (string ) (HString ) (char* )
Name of the layer to be queried.
WeightsType WeightsType WeightsType WeightsType weightsType weights_type
(input_control) string →
HTuple str HTuple Htuple (string) (string ) (HString ) (char* )
Selected type of layer values to be returned.
Default value:
'weights'
"weights"
"weights"
"weights"
"weights"
"weights"
List of values: 'batchnorm_mean' "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_mean_avg" , 'batchnorm_variance' "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" "batchnorm_variance_avg" , 'bias' "bias" "bias" "bias" "bias" "bias" , 'bias_gradient' "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_gradient_norm_l2" , 'bias_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" , 'bias_update_norm_l2' "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" , 'weights_gradient' "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_gradient_norm_l2" , 'weights_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" , 'weights_update_norm_l2' "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_model create_dl_model CreateDlModel CreateDlModel CreateDlModel create_dl_model
,
train_dl_classifier_batch train_dl_classifier_batch TrainDlClassifierBatch TrainDlClassifierBatch TrainDlClassifierBatch train_dl_classifier_batch
,
set_dl_model_layer_weights set_dl_model_layer_weights SetDlModelLayerWeights SetDlModelLayerWeights SetDlModelLayerWeights set_dl_model_layer_weights
Possible Successors
set_dl_model_layer_weights set_dl_model_layer_weights SetDlModelLayerWeights SetDlModelLayerWeights SetDlModelLayerWeights set_dl_model_layer_weights
Alternatives
get_dl_model_layer_activations get_dl_model_layer_activations GetDlModelLayerActivations GetDlModelLayerActivations GetDlModelLayerActivations get_dl_model_layer_activations
,
get_dl_model_layer_gradients get_dl_model_layer_gradients GetDlModelLayerGradients GetDlModelLayerGradients GetDlModelLayerGradients get_dl_model_layer_gradients
Module
Deep Learning Training