public class KerasLayer extends Object
Modifier and Type | Class and Description |
---|---|
static class |
KerasLayer.DimOrder |
Modifier and Type | Field and Description |
---|---|
protected String |
className |
protected KerasLayerConfiguration |
conf |
protected KerasLayer.DimOrder |
dimOrder |
protected double |
dropout |
protected List<String> |
inboundLayerNames |
protected int[] |
inputShape |
protected Integer |
kerasMajorVersion |
protected Layer |
layer |
protected String |
layerName |
protected GraphVertex |
vertex |
protected double |
weightL1Regularization |
protected double |
weightL2Regularization |
protected Map<String,org.nd4j.linalg.api.ndarray.INDArray> |
weights |
Modifier | Constructor and Description |
---|---|
protected |
KerasLayer()
Default constructor.
|
protected |
KerasLayer(Integer kerasVersion)
Constructor with Keras version only.
|
protected |
KerasLayer(Map<String,Object> layerConfig)
Constructor.
|
protected |
KerasLayer(Map<String,Object> layerConfig,
boolean enforceTrainingConfig)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
copyWeightsToLayer(Layer layer)
Copy Keras layer weights to DL4J Layer.
|
String |
getClassName()
Get Keras layer class name.
|
protected KerasLayer.DimOrder |
getDimOrder()
Get Keras layer backend dimension order.
|
List<String> |
getInboundLayerNames()
Get list of inbound layers.
|
InputPreProcessor |
getInputPreprocessor(InputType... inputType)
Gets appropriate DL4J InputPreProcessor for given InputTypes.
|
int[] |
getInputShape()
Get layer input shape.
|
Integer |
getKerasMajorVersion()
Get Keras major version of this layer.
|
Layer |
getLayer()
Gets corresponding DL4J Layer, if any.
|
String |
getLayerName()
Get Keras layer name.
|
int |
getNumParams()
Returns number of trainable parameters in layer.
|
InputType |
getOutputType(InputType... inputType)
Get layer output type.
|
GraphVertex |
getVertex()
Gets corresponding DL4J Vertex, if any.
|
Map<String,org.nd4j.linalg.api.ndarray.INDArray> |
getWeights() |
boolean |
isInputPreProcessor()
Whether this Keras layer maps to a DL4J InputPreProcessor.
|
boolean |
isLayer()
Whether this Keras layer maps to a DL4J Layer.
|
boolean |
isValidInboundLayer()
Indicates whether this layer a valid inbound layer.
|
boolean |
isVertex()
Whether this Keras layer maps to a DL4J Vertex.
|
static void |
registerCustomLayer(String layerName,
Class<? extends KerasLayer> configClass)
Register a custom layer
|
void |
setInboundLayerNames(List<String> inboundLayerNames)
Set list of inbound layers.
|
void |
setWeights(Map<String,org.nd4j.linalg.api.ndarray.INDArray> weights)
Set weights for Keras layer.
|
boolean |
usesRegularization()
Indicates whether layer uses regularization.
|
protected String className
protected String layerName
protected int[] inputShape
protected KerasLayer.DimOrder dimOrder
protected Layer layer
protected GraphVertex vertex
protected double weightL1Regularization
protected double weightL2Regularization
protected double dropout
protected Integer kerasMajorVersion
protected KerasLayerConfiguration conf
protected KerasLayer(Integer kerasVersion) throws UnsupportedKerasConfigurationException
kerasVersion
- major Keras version (1 or 2)UnsupportedKerasConfigurationException
- Unsupported Keras configurationprotected KerasLayer() throws UnsupportedKerasConfigurationException
UnsupportedKerasConfigurationException
- Unsupported Keras configurationprotected KerasLayer(Map<String,Object> layerConfig) throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException
layerConfig
- dictionary containing Keras layer configurationInvalidKerasConfigurationException
UnsupportedKerasConfigurationException
protected KerasLayer(Map<String,Object> layerConfig, boolean enforceTrainingConfig) throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException
layerConfig
- dictionary containing Keras layer configurationenforceTrainingConfig
- whether layer should be built for training (controls certain exceptions)InvalidKerasConfigurationException
UnsupportedKerasConfigurationException
public static void registerCustomLayer(String layerName, Class<? extends KerasLayer> configClass)
layerName
- name of custom layerconfigClass
- class of custom layerpublic Integer getKerasMajorVersion()
public String getClassName()
public String getLayerName()
public int[] getInputShape()
protected KerasLayer.DimOrder getDimOrder()
public List<String> getInboundLayerNames()
public void setInboundLayerNames(List<String> inboundLayerNames)
inboundLayerNames
- list of inbound layer naemspublic int getNumParams()
public boolean usesRegularization()
public void setWeights(Map<String,org.nd4j.linalg.api.ndarray.INDArray> weights) throws InvalidKerasConfigurationException
weights
- Map of named NDArraysInvalidKerasConfigurationException
public void copyWeightsToLayer(Layer layer) throws InvalidKerasConfigurationException
layer
- DL4J layerInvalidKerasConfigurationException
- Invalid Keras configurationpublic boolean isLayer()
public Layer getLayer()
Layer
public boolean isVertex()
public GraphVertex getVertex()
GraphVertex
public boolean isInputPreProcessor()
public InputPreProcessor getInputPreprocessor(InputType... inputType) throws InvalidKerasConfigurationException
inputType
- Array of InputTypesInvalidKerasConfigurationException
- Invalid Keras configurationInputPreProcessor
public InputType getOutputType(InputType... inputType) throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException
inputType
- Array of InputTypesInvalidKerasConfigurationException
- Invalid Keras configurationUnsupportedKerasConfigurationException
public boolean isValidInboundLayer() throws InvalidKerasConfigurationException
InvalidKerasConfigurationException
Layer
Copyright © 2018. All rights reserved.