When I import KerasModel and try to print the details of each layer and vertex. Flatten layer in
keras which in dl4j VertexType is PreprocessorVertex. And I try to use method and then throw ArrayIndexOutOfBoundsException
kerasLayer.isValidInboundLayer()
All Code:
//Summary
ComputationGraph model = KerasModelImport.importKerasModelAndWeights(path);
System.out.println(model.summary());
//each KerasLayer
KerasModel kerasModel = (new KerasModel()).modelBuilder().modelHdf5Filename(path).enforceTrainingConfig(true).buildModel();
Map<String, KerasLayer> kerasModelLayers = kerasModel.getLayers();
for (Map.Entry<String, KerasLayer> layerEntry : kerasModelLayers.entrySet()) {
System.out.println(layerEntry.getKey());
KerasLayer kerasLayer = layerEntry.getValue();
System.out.println("isVertex " + kerasLayer.isVertex());
System.out.println("isInputPreProcessor " + kerasLayer.isInputPreProcessor());
System.out.println("isInputPreProcessor " + kerasLayer.isLayer());
System.out.println("isValidInboundLayer " + kerasLayer.isValidInboundLayer());
}
================================================================================================================
VertexName (VertexType) nIn,nOut TotalParams ParamsShape Vertex Inputs
================================================================================================================
input_wide (InputVertex) -,- - - -
input_deep (InputVertex) -,- - - -
input_emb (InputVertex) -,- - - -
emb_cate_code (EmbeddingSequenceLayer) 19,8 152 W:{19,8} [input_emb]
flatten (PreprocessorVertex) -,- - - [emb_cate_code]
concatenate (MergeVertex) -,- - - [input_deep, flatten]
hidden1 (DenseLayer) 31,128 4,096 W:{31,128}, b:{1,128} [concatenate]
hidden2 (DenseLayer) 128,256 33,024 W:{128,256}, b:{1,256} [hidden1]
hidden3 (DenseLayer) 256,128 32,896 W:{256,128}, b:{1,128} [hidden2]
concatenate_1 (MergeVertex) -,- - - [input_wide, hidden3]
dense (DenseLayer) 172,1 173 W:{172,1}, b:{1,1} [concatenate_1]
dense_loss (LossLayer) -,- 0 - [dense]
----------------------------------------------------------------------------------------------------------------