setNetwork - Assign dlnetwork object as the state or output function of a neural state-space model - MATLAB - MathWorks 日本 (2024)

Assign dlnetwork object as the state or output function of a neural state-space model

Since R2024b

collapse all in page

    Syntax

    nss = setNetwork(nss,type,dlnet)

    nss = setNetwork(nss,type,dlnet,Name=Value)

    Description

    You can use dlnetwork objects to approximate the state or non-trivial part of the output function of a neural state-space model. A dlnetwork object supports more network structures when compared to the multi-layer perceptron network created using createMLPNetwork. Use setNetwork to map the input layers of the network to the corresponding state, input, and time of the neural state-space model.

    As an alternative to setNetwork, you can directly assign a dlnetwork object to the StateNetwork and OutputNetwork properties of an idNeuralStateSpace object. To do so, the dlnetwork object must have a configuration as specified in dlnet. In this case, the software maps the input layers of the dlnetwork object to the corresponding state, input, and time of the idNeuralStateSpace object by comparing the layer sizes with the number of states and inputs. If the layer sizes are not distinguishable, that is, if the number of states and inputs are equal, then the software maps the layers in the order of state, input, and time.

    For more information on neural state-space models and their structure, see What are Neural State-Space Models?.

    nss = setNetwork(nss,type,dlnet) approximates either the state or (non-trivial part of) the output function of the neural state-space object nss, depending on type, by assigning the custom dlnetwork object dlnet to the idNeuralStateSpace object nss. It maps the input layers of dlnet to the corresponding state, input, and time of the neural state-space model by comparing the size of the layers with the number of states and inputs.

    For example, to assign the network dlnet to the state function, use

    nss = setNetwork(nss,"state",dlnet)

    This command is equivalent to nss.StateNetwork = dlnet.

    To assign the network to the non-trivial part of the output function, use

    nss = setNetwork(nss,"output",dlnet)

    This command is equivalent to nss.OutputNetwork = dlnet.

    example

    nss = setNetwork(nss,type,dlnet,Name=Value) specifies name-value arguments after the input arguments in the previous syntax.

    When the input layer sizes are not distinguishable, use the name-value arguments to manually assign the input layers of the network to the corresponding state, input, and time of the neural state-space model.

    For example, to assign the network dlnet to the state function and map input layers with names "State" and "Input" to the state and input of the neural state-space model, respectively, use

    nss = setNetwork(nss,"state",dlnet,xName="State",uName="Input")

    example

    Examples

    collapse all

    Assign a Network with Different Layer Sizes as the State Function of a Neural State-Space Model

    This example uses:

    • System Identification ToolboxSystem Identification Toolbox
    • Deep Learning ToolboxDeep Learning Toolbox

    Open Live Script

    Use idNeuralStateSpace to create a continuous-time neural state-space object with two states and one input. By default, the state function network has two hidden layers each with 64 neurons and a hyperbolic tangent activation function.

    nss = idNeuralStateSpace(2,NumInputs=1)
    nss =Continuous-time Neural ODE in 2 variables dx/dt = f(x(t),u(t)) y(t) = x(t) + e(t) f(.) network: Deep network with 2 fully connected, hidden layers Activation function: tanh Variables: x1, x2 Status: Created by direct construction or transformation. Not estimated.

    Create a custom dlnetwork object with two featureInputLayers of sizes equal to the number of states and inputs. Specify two hidden layers of 4 and 8 neurons, respectively, and use relu as the activation function. Specify one output layer of size equal to the number of states.

    layer1 = featureInputLayer(2,Name="state");layer2 = featureInputLayer(1,Name="input");layer3 = [ ... concatenationLayer(1,2,Name="concat") fullyConnectedLayer(4,Name="fc1") reluLayer(Name="act1") fullyConnectedLayer(8,Name="fc2") reluLayer(Name="act2") fullyConnectedLayer(2,Name="dx")];dlnet = dlnetwork(layer3,Initialize=false);dlnet = addLayers(dlnet,layer1);dlnet = addLayers(dlnet,layer2);dlnet = connectLayers(dlnet, "state", "concat/in1");dlnet = connectLayers(dlnet, "input", "concat/in2");plot(dlnet)

    setNetwork - Assign dlnetwork object as the state or output function of aneural state-space model - MATLAB- MathWorks 日本 (1)

    Initialize the network.

    dlnet = initialize(dlnet);

    To re-configure the state function network of nss, directly assign the custom network dlnet to the StateNetwork property of nss. As the input layer sizes of the network are distinguishable, the software automatically maps the input layers to the corresponding state and input of nss.

    nss.StateNetwork = dlnet;

    You can also use setNetwork to assign the custom network.

    nss = setNetwork(nss,"state",dlnet);

    You can now use time-domain data to perform estimation and validation.

    Assign a Network with Equal Layer Sizes as the State Function of a Neural State-Space Model

    This example uses:

    • System Identification ToolboxSystem Identification Toolbox
    • Deep Learning ToolboxDeep Learning Toolbox

    Open Live Script

    Use idNeuralStateSpace to create a continuous-time neural state-space object with one state and one input. By default, the state function network has two hidden layers each with 64 neurons and a hyperbolic tangent activation function.

    nss = idNeuralStateSpace(1,NumInputs=1)
    nss =Continuous-time Neural ODE in 1 variables dx/dt = f(x(t),u(t)) y(t) = x(t) + e(t) f(.) network: Deep network with 2 fully connected, hidden layers Activation function: tanh Variables: x1 Status: Created by direct construction or transformation. Not estimated.

    Create a custom dlnetwork object with two featureInputLayers of sizes equal to the number of states and inputs. Specify two hidden layers of 4 and 8 neurons, respectively, and use relu as the activation function. Specify one output layer of size equal to the number of states.

    layer1 = featureInputLayer(1,Name="state");layer2 = featureInputLayer(1,Name="input");layer3 = [ ... concatenationLayer(1,2,Name="concat") fullyConnectedLayer(4,Name="fc1") reluLayer(Name="act1") fullyConnectedLayer(8,Name="fc2") reluLayer(Name="act2") fullyConnectedLayer(1,Name="dx")];dlnet = dlnetwork(layer3,Initialize=false);dlnet = addLayers(dlnet,layer1);dlnet = addLayers(dlnet,layer2);dlnet = connectLayers(dlnet, "state", "concat/in1");dlnet = connectLayers(dlnet, "input", "concat/in2");plot(dlnet)

    setNetwork - Assign dlnetwork object as the state or output function of aneural state-space model - MATLAB- MathWorks 日本 (2)

    Initialize the network.

    dlnet = initialize(dlnet);

    To re-configure the state function network of nss, assign the custom network dlnet to nss. Because both the state and input layers have the same size, use setNetwork with name-value pair arguments to assign the input layers of the custom network to the corresponding state and input of nss.

    nss = setNetwork(nss,"state",dlnet,xName="state",uName="input");

    You can now use time-domain data to perform estimation and validation.

    Input Arguments

    collapse all

    nssNeural state-space system
    idNeuralStateSpace object

    Neural state-space system, specified as an idNeuralStateSpace object.

    Example: idNeuralStateSpace(2,NumInputs=1)

    typeNetwork type
    "state" | "output"

    Network type, specified as one of the following:

    • "state" — assigns the network to nss to approximate the state function of the model. For continuous state-space systems the state function returns the system state derivative with respect to time, while for discrete-time state-space systems it returns the next state. The inputs of the state function are time (if IsTimeInvariant is false), the current state, and the current input (if NumInputs is positive).

    • "output" — assigns the network to nss to approximate the non-trivial part of the output function of the model. This network returns the non-trivial system output, y2(t) = H(t,x,u), as a function of time (if IsTimeInvariant is false), the current state, and the current input (if NumInputs is positive and HasFeedthrough is true). For more information, see idNeuralStateSpace.

    dlnetCustom network to approximate the state or output function
    dlnetwork object

    Custom network to approximate the state or output function of nss, specified as a dlnetwork (Deep Learning Toolbox) object with the following configuration:

    • The input layers of the custom network must all be of type featureInputLayer (Deep Learning Toolbox). The network must have one featureInputLayer of size equal to the number of states (nx). For time-varying models, the network must have one featureInputLayer of size 1. In addition, if the model uses input signals (that is, if nu > 0):

      • To approximate the state function, the network must have one featureInputLayer of size equal to the number of inputs (nu)

      • To approximate the output function, the network must have one featureInputLayer of size equal to the number of inputs (nu) only if the HasFeedthrough argument of the idNeuralStateSpace object is set to true.

    • The network must contain exactly one output layer. To approximate the state function, the output layer size must be equal to the number of model states. To approximate the output function, the size must be equal to the number of additional outputs (that is, ny - nx, where ny is the total number of model outputs).

    You can use the Deep Network Designer (Deep Learning Toolbox) app to design the network or use the command dlnetwork (Deep Learning Toolbox).

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: xName="st1"

    Use name-value arguments to manually assign the input layers of the custom network to the state, input, and time of the neural state-space model when the layer sizes are not distinguishable.

    xNameNetwork input layer name corresponding to state or output
    string | character array

    Network input layer name corresponding to state or output (x) of nss, specified as a string or character array.

    If the type is "state", xName is the name of the input layer corresponding to the state network of nss. If the type is "output", xName is the name of the input layer corresponding to the output network of nss.

    Example: "State"

    uNameNetwork input layer name corresponding to input
    string | character array

    Network input layer name corresponding to input (u) of nss, specified as a string or character array.

    Example: "Input"

    tNameNetwork input layer name corresponding to time
    string | character array

    Network input layer name corresponding to time (t) of nss, specified as a string or character array.

    Example: "Time"

    Version History

    Introduced in R2024b

    See Also

    Objects

    • idNeuralStateSpace | nssTrainingADAM | nssTrainingSGDM | nssTrainingRMSProp | nssTrainingLBFGS | idss | idnlgrey

    Functions

    • createMLPNetwork | nssTrainingOptions | nlssest | generateMATLABFunction | idNeuralStateSpace/evaluate | idNeuralStateSpace/linearize | sim

    Live Editor Tasks

    • Estimate Neural State-Space Model

    Blocks

    • Neural State-Space Model

    Topics

    • What are Neural State-Space Models?
    • Estimate Neural State-Space System
    • Estimate Nonlinear Autonomous Neural State-Space System
    • Neural State-Space Model of Simple Pendulum System
    • Augment Known Linear Model with Flexible Nonlinear Functions

    MATLAB コマンド

    次の MATLAB コマンドに対応するリンクがクリックされました。

     

    コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。

    setNetwork - Assign dlnetwork object as the state or output function of aneural state-space model - MATLAB- MathWorks 日本 (3)

    Select a Web Site

    Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

    You can also select a web site from the following list:

    Americas

    • América Latina (Español)
    • Canada (English)
    • United States (English)

    Europe

    • Belgium (English)
    • Denmark (English)
    • Deutschland (Deutsch)
    • España (Español)
    • Finland (English)
    • France (Français)
    • Ireland (English)
    • Italia (Italiano)
    • Luxembourg (English)
    • Netherlands (English)
    • Norway (English)
    • Österreich (Deutsch)
    • Portugal (English)
    • Sweden (English)
    • Switzerland
      • Deutsch
      • English
      • Français
    • United Kingdom (English)

    Asia Pacific

    • Australia (English)
    • India (English)
    • New Zealand (English)
    • 中国
    • 日本 (日本語)
    • 한국 (한국어)

    Contact your local office

    setNetwork - Assign dlnetwork object as the state or output function of a
neural state-space model - MATLAB
- MathWorks 日本 (2024)

    References

    Top Articles
    Latest Posts
    Recommended Articles
    Article information

    Author: Jamar Nader

    Last Updated:

    Views: 5789

    Rating: 4.4 / 5 (75 voted)

    Reviews: 90% of readers found this page helpful

    Author information

    Name: Jamar Nader

    Birthday: 1995-02-28

    Address: Apt. 536 6162 Reichel Greens, Port Zackaryside, CT 22682-9804

    Phone: +9958384818317

    Job: IT Representative

    Hobby: Scrapbooking, Hiking, Hunting, Kite flying, Blacksmithing, Video gaming, Foraging

    Introduction: My name is Jamar Nader, I am a fine, shiny, colorful, bright, nice, perfect, curious person who loves writing and wants to share my knowledge and understanding with you.