DL4J中文文档/Keras模型导入/循环层

 

KerasLSTM

[源码]

导入一个Keras的LSTM层作为DL4J的LSTM层。

KerasLSTM

public KerasLSTM(Integer kerasVersion) throws UnsupportedKerasConfigurationException 

从KerasLayer传递构造函数

  • 参数 kerasVersion Keras主版本
  • 抛出 UnsupportedKerasConfigurationException 不支持的 Keras 配置

getLSTMLayer

public Layer getLSTMLayer() 

获取LSTM层

public KerasLstm(Map<String, Object> layerConfig)
                    throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException

来自解析的keras层配置字典的构造函数。

  • 参数 layerConfig 包含keras层配置的字典
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置
  • 抛出 UnsupportedKerasConfigurationException 不支持的无效的 Keras 配置

getOutputType

public InputType getOutputType(InputType... inputType) throws InvalidKerasConfigurationException 

获取层输出类型

  • 参数 inputType 输入类型数组
  • 返回 按输入类型返回输出类型
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置

getNumParams

public int getNumParams() 

返回层中可训练参数的数目。

getInputPreprocessor

public InputPreProcessor getInputPreprocessor(InputType... inputType) throws InvalidKerasConfigurationException 

为给定的输入类型获取适合的DL4J输入预处理器

  • 参数 inputType 输入类型数组
  • 返回 DL4J 输入预处理器
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置
  • 查看  org.deeplearning4j.nn.conf.InputPreProcessor

setWeights

public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException 

为层设置权重。

  • 参数 weights LSTM 层权重

getUnroll

public boolean getUnroll() 

获取是否应展开LSTM层(对于截断的BPTT)。

  • 返回是否应展开LSTM层

getGateActivationFromConfig

public IActivation getGateActivationFromConfig(Map<String, Object> layerConfig)
            throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException 

从Keras层配置中获取LSTM门激活函数。

  • 参数 layerConfig 包含keras层配置的字典
  • 返回 LSTM 内部激法函数
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置

getForgetBiasInitFromConfig

public double getForgetBiasInitFromConfig(Map<String, Object> layerConfig, boolean train)
            throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException 

从keras层配置中获取lstm 遗忘门偏置初始化。

  • 参数 layerConfig 包含keras层配置的字典
  • 返回lstm遗忘门偏置初始化
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置

KerasRnnUtils

[源码]

keras rnn层的实用功能

getUnrollRecurrentLayer

public static boolean getUnrollRecurrentLayer(KerasLayerConfiguration conf, Map<String, Object> layerConfig)
            throws InvalidKerasConfigurationException 

获取unroll参数以决定是否使用BPTT展开rnn。

  • 参数 conf 为Keras层配置
  • 参数 layerConfig 包含keras层属性的字典
  • 返回 boolean 值的展开参数
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置

getRecurrentDropout

public static double getRecurrentDropout(KerasLayerConfiguration conf, Map<String, Object> layerConfig)
            throws UnsupportedKerasConfigurationException, InvalidKerasConfigurationException 

Get recurrent weight dropout from Keras layer configuration. Non-zero dropout rates are currently not supported.

从Keras层配置中获得权重dropout。当前不支持非零dropout。

  • 参数 conf 为Keras层配置
  • 参数 layerConfig 包含keras层属性的字典
  • 返回循环dropout率
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置

KerasSimpleRnn

[源码]

导入一个Keras的SimpleRNN层作为一个DL4J的SimpleRnn层。

KerasSimpleRnn

public KerasSimpleRnn(Integer kerasVersion) throws UnsupportedKerasConfigurationException 

从KerasLayer传递构造函数

  • 参数 kerasVersion Keras主版本
  • 抛出 UnsupportedKerasConfigurationException 不支持的 Keras 配置

getSimpleRnnLayer

public Layer getSimpleRnnLayer() 

获取SimpleRnn层。

public KerasSimpleRnn(Map<String, Object> layerConfig)
            throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException 

来自解析的keras层配置字典的构造函数。

  • 参数 layerConfig 包含keras层配置的字典
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置
  • 抛出 UnsupportedKerasConfigurationException 不支持的无效的 Keras 配置

getOutputType

public InputType getOutputType(InputType... inputType) throws InvalidKerasConfigurationException 

获取层输出类型

  • 参数 inputType 输入类型数组
  • 返回 按输入类型返回输出类型
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置

getNumParams

public int getNumParams() 

返回层中可训练参数的数目。

getInputPreprocessor

public InputPreProcessor getInputPreprocessor(InputType... inputType) throws InvalidKerasConfigurationException 

为给定的输入类型获取适合的DL4J输入预处理器

  • 参数 inputType 输入类型数组
  • 返回 DL4J 输入预处理器
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置
  • 查看  org.deeplearning4j.nn.conf.InputPreProcessor

getUnroll

public boolean getUnroll() 

获取是否应展开SimpleRNN层(对于截断的BPTT)。

  • 返回是否应展开SimpleRNN层

setWeights

public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException 

为层设置权重。

  • 参数  weights 简单的RNN权重
  • 抛出 InvalidKerasConfigurationException 无效的 Keras 配置

猜你喜欢

转载自blog.csdn.net/bewithme/article/details/86527299