%% Import Keras Network Architecture and Weights from Same File
% Specify the network file to import layers and weights from.

modelfile = 'digitsDAGnet.h5';

% Import the network architecture and weights from the files you specified. To import the layer weights, specify 'ImportWeights' to be true. The function also imports the layers with their weights from the same HDF5 file.

layers = importKerasLayers(modelfile,'ImportWeights',true)

% View the size of the weights in the second layer.

weights = layers.Layers(2).Weights;
size(weights)

% The function has imported the weights so the layer weights are non-empty.
% Copyright 2018 The MathWorks, Inc.