Main Content

saveModel

Save detector network and parameters

Since R2024a

    Description

    saveModel(d) creates a MAT-file in the current directory containing the trained network and parameters corresponding to the signal anomaly detector d. You can use the generated file with the Deep Signal Anomaly Detector Simulink® block. The generated file contains two variables:

    • detectorModel — A dlnetwork (Deep Learning Toolbox) object that stores the trained network corresponding to d.

    • detectorParameters — A structure that contains the detection parameters used by d, including the window length, the overlap length, and the threshold.

    By default, the name of the generated file is the name of the detector with Data appended.

    To load the trained network and detector parameters into the Deep Signal Anomaly Detector block, provide the path and file name of the generated MAT-file in the block dialog box.

    Note

    You must train the signal anomaly detector before calling saveModel.

    example

    saveModel(d,filename) specifies the file name and path for the generated file.

    Examples

    collapse all

    Load a convolutional anomaly detector trained with three-channel sinusoidal signals. Display the model, threshold, and window properties of the detector.

    load sineWaveAnomalyDetector
    D
    D = 
      deepSignalAnomalyDetectorCNN with properties:
    
                    IsTrained: 1
                  NumChannels: 3
    
       Model Information
                    ModelType: 'convautoencoder'
                   FilterSize: 8
                   NumFilters: 32
          NumDownsampleLayers: 2
             DownsampleFactor: 2
           DropoutProbability: 0.2000
    
       Threshold Information
                    Threshold: 0.0510
              ThresholdMethod: 'contaminationFraction'
           ThresholdParameter: 0.0100
    
       Window Information
                 WindowLength: 1
                OverlapLength: 'auto'
        WindowLossAggregation: 'mean'
    
    

    Create a MAT-file in the current directory containing the trained network and parameters corresponding to D. By default, the name of the file is the name of the detector with Data appended. Load the file to see the contents of the structure.

    saveModel(D)
    
    ls D*.mat
    DData.mat
    
    str = load("DData")
    str = struct with fields:
             detectorModel: [1x1 dlnetwork]
        detectorParameters: [1x1 struct]
    
    

    Input Arguments

    collapse all

    Anomaly detector, specified as a deepSignalAnomalyDetectorCNN object, a deepSignalAnomalyDetectorLSTM object, or a deepSignalAnomalyDetectorLSTMForecaster object. Use the deepSignalAnomalyDetector function to create d.

    File name and path, specified as a character vector or string.

    Example: "DetectorNetwork.mat"

    Example: '../dir/models/AnomalyDetectorModel.mat'

    Example: "C:\dir\DetectorModel"

    Data Types: char | string

    Version History

    Introduced in R2024a