PlaceholderLayer
Layer replacing an unsupported Keras or ONNX layer
PlaceholderLayer
is not recommended. Use importNetworkFromTensorFlow
or importNetworkFromONNX
to import a Keras or ONNX™ network as a dlnetwork
object with custom
layers.
Description
PlaceholderLayer
is a layer that importKerasLayers
and importONNXLayers
insert into a layer array or layer graph in place of an
unsupported Keras or ONNX layer.
Creation
Importing layers from a Keras or ONNX network that has layers that are not supported by Deep Learning Toolbox™ creates PlaceholderLayer
objects.
Properties
Name
— Layer name
character vector | string scalar
Layer name, specified as a character vector or a string scalar.
Data Types: char
| string
Description
— Layer description
character vector | string scalar
Layer description, specified as a character vector or a string scalar.
Data Types: char
| string
Type
— Layer type
character vector | string scalar
Layer type, specified as a character vector or a string scalar.
Data Types: char
| string
KerasConfiguration
— Keras configuration of layer
structure
Keras configuration of a layer, specified as a structure. The fields of the structure depend on the layer type.
Note
This property only exists if the layer was created when importing a Keras network.
Data Types: struct
ONNXNode
— ONNX configuration of layer
structure
ONNX configuration of a layer, specified as a structure. The fields of the structure depend on the layer type.
Note
This property only exists if the layer was created when importing an ONNX network.
Data Types: struct
Weights
— Imported weights
structure
Imported weights, specified as a structure.
Data Types: struct
Examples
Find and Explore Placeholder Layers
Specify the Keras network file to import layers from.
modelfile = 'digitsDAGnetwithnoise.h5';
Import the network architecture. The network includes some layer types that are not supported by Deep Learning Toolbox. The importKerasLayers
function replaces each unsupported layer with a placeholder layer and returns a warning message.
lgraph = importKerasLayers(modelfile)
Warning: "importKerasLayers" is not recommended and will be removed in a future release. To import TensorFlow-Keras models, save using the SavedModel format and use importNetworkFromTensorFlow function.
Warning: Unable to import some Keras layers, because they are not supported by the Deep Learning Toolbox. They have been replaced by placeholder layers. To find these layers, call the function findPlaceholderLayers on the returned object.
lgraph = LayerGraph with properties: InputNames: {'input_1'} OutputNames: {'ClassificationLayer_activation_1'} Layers: [15x1 nnet.cnn.layer.Layer] Connections: [15x2 table]
Display the imported layers of the network. Two placeholder layers replace the Gaussian noise layers in the Keras network.
lgraph.Layers
ans = 15x1 Layer array with layers: 1 'input_1' Image Input 28x28x1 images 2 'conv2d_1' 2-D Convolution 20 7x7 convolutions with stride [1 1] and padding 'same' 3 'conv2d_1_relu' ReLU ReLU 4 'conv2d_2' 2-D Convolution 20 3x3 convolutions with stride [1 1] and padding 'same' 5 'conv2d_2_relu' ReLU ReLU 6 'gaussian_noise_1' GaussianNoise Placeholder for "GaussianNoise" Keras layer 7 'gaussian_noise_2' GaussianNoise Placeholder for "GaussianNoise" Keras layer 8 'max_pooling2d_1' 2-D Max Pooling 2x2 max pooling with stride [2 2] and padding 'same' 9 'max_pooling2d_2' 2-D Max Pooling 2x2 max pooling with stride [2 2] and padding 'same' 10 'flatten_1' Keras Flatten Flatten activations into 1-D assuming C-style (row-major) order 11 'flatten_2' Keras Flatten Flatten activations into 1-D assuming C-style (row-major) order 12 'concatenate_1' Depth concatenation Depth concatenation of 2 inputs 13 'dense_1' Fully Connected 10 fully connected layer 14 'activation_1' Softmax softmax 15 'ClassificationLayer_activation_1' Classification Output crossentropyex
Find the placeholder layers using findPlaceholderLayers
. The output argument contains the two placeholder layers that importKerasLayers
inserted in place of the Gaussian noise layers of the Keras network.
placeholders = findPlaceholderLayers(lgraph)
placeholders = 2x1 PlaceholderLayer array with layers: 1 'gaussian_noise_1' GaussianNoise Placeholder for "GaussianNoise" Keras layer 2 'gaussian_noise_2' GaussianNoise Placeholder for "GaussianNoise" Keras layer
Specify a name for each placeholder layer.
gaussian1 = placeholders(1); gaussian2 = placeholders(2);
Display the configuration of each placeholder layer.
gaussian1.KerasConfiguration
ans = struct with fields:
trainable: 1
name: 'gaussian_noise_1'
stddev: 1.5000
inbound_nodes: {{1x1 cell}}
gaussian2.KerasConfiguration
ans = struct with fields:
trainable: 1
name: 'gaussian_noise_2'
stddev: 0.7000
inbound_nodes: {{1x1 cell}}
Version History
Introduced in R2017bR2024a: PlaceholderLayer
is not recommended
PlaceholderLayer
is not recommended. Use importNetworkFromTensorFlow
or importNetworkFromONNX
to import a Keras or ONNX network as a dlnetwork
object with custom
layers.
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
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:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
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
- United Kingdom (English)