Clear Filters
Clear Filters

Convert a LayerGraph into a DAGNetwork - Validate and Initialize the Net

37 views (last 30 days)
In theory, the function assembleNetwork() should convert a LayerGraph into a DAGNetwork.
Yet in practice, it doesn't always work:
numRows = 64;
numCols = 64;
numChannels = 3;
numClasses = 3;
assembleNetwork(unetLayers([numRows, numCols, numChannels], numClasses));
Warning: Network issues detected.

Caused by:
Layer 'Segmentation-Layer': Empty Classes property. Classes will be set to categorical(1:N), where N is the number of classes.
Error using assembleNetwork (line 47)
Invalid network.

Caused by:
Layer 'Bridge-Conv-1': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Bridge-Conv-1': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Bridge-Conv-2': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Bridge-Conv-2': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-1-Conv-1': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-1-Conv-1': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-1-Conv-2': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-1-Conv-2': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-1-UpConv': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-1-UpConv': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-2-Conv-1': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-2-Conv-1': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-2-Conv-2': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-2-Conv-2': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-2-UpConv': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-2-UpConv': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-3-Conv-1': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-3-Conv-1': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-3-Conv-2': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-3-Conv-2': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-3-UpConv': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-3-UpConv': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-4-Conv-1': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-4-Conv-1': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-4-Conv-2': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-4-Conv-2': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Decoder-Stage-4-UpConv': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Decoder-Stage-4-UpConv': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Encoder-Stage-1-Conv-1': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Encoder-Stage-1-Conv-1': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Encoder-Stage-1-Conv-2': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Encoder-Stage-1-Conv-2': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Encoder-Stage-2-Conv-1': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Encoder-Stage-2-Conv-1': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Encoder-Stage-2-Conv-2': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Encoder-Stage-2-Conv-2': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Encoder-Stage-3-Conv-1': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Encoder-Stage-3-Conv-1': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Encoder-Stage-3-Conv-2': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Encoder-Stage-3-Conv-2': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Encoder-Stage-4-Conv-1': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Encoder-Stage-4-Conv-1': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Encoder-Stage-4-Conv-2': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Encoder-Stage-4-Conv-2': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'Final-ConvolutionLayer': Empty Weights property. Specify a nonempty value for the Weights property.
Layer 'Final-ConvolutionLayer': Empty Bias property. Specify a nonempty value for the Bias property.
Layer 'ImageInputLayer': Empty Mean property. For an image input layer with 'zerocenter' normalization, specify a nonempty value for the Mean property.
My question is, how can I convert myNet = unetLayers([numRows, numCols, numChannels], numClasses) into an initialized and validated network so I can use it for prediction (It will be garbage in garbage out as the net is randomly initialized, but I'm after the action of the conversion)?

Answers (1)

yanqi liu
yanqi liu on 3 Dec 2021
yes,sir,may be use assembleNetwork for pretrained layers,if make an init empty unet,may be just use
clc; clear all; close all;
numRows = 64;
numCols = 64;
numChannels = 3;
numClasses = 3;
lgraph = unetLayers([numRows, numCols, numChannels], numClasses)
lgraph =
LayerGraph with properties: Layers: [58×1 nnet.cnn.layer.Layer] Connections: [61×2 table] InputNames: {'ImageInputLayer'} OutputNames: {'Segmentation-Layer'}
% assembleNetwork(lgraph)
plot(lgraph)

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!