%% Create Uninitialized dlnetwork
% Create an uninitialized dlnetwork object without an input layer. Creating an uninitialized dlnetwork is useful when you do not yet know the size and format of the network inputs, for example, when the dlnetwork is nested inside a custom layer.
% Define the network layers. This network has a single input, which is not connected to an input layer.

layers = [
    convolution2dLayer(5,20)
    batchNormalizationLayer
    reluLayer
    fullyConnectedLayer(10)
    softmaxLayer];

% Create an uninitialized dlnetwork. Set the Initialize option to false.

dlnet = dlnetwork(layers,'Initialize',false);

% Check that the network is not initialized.

dlnet.Initialized

% The learnable and state parameters of this network are not initialized for training. To initialize the network, use the initialize function.
% If you want to use dlnet directly in a custom training loop, then you can initialize it by using the initialize function and providing an example input.
% If you want to use dlnet inside a custom layer, then you can take advantage of automatic initialization. If you use the custom layer inside a dlnetwork, then dlnet is initialized when the parent dlnetwork is constructed (or when the parent network is initialized if it is constructed as an uninitialized dlnetwork). If you use the custom layer inside a network that is trained using the trainNetwork function, then dlnet is automatically initialized at training time. For more information, see Deep Learning Network Compostition.
% Copyright 2021 The MathWorks, Inc.