org.deeplearning4j.nn.conf.layers.BaseOutputLayer Java Examples

The following examples show how to use org.deeplearning4j.nn.conf.layers.BaseOutputLayer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseNetConfigDeserializer.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
protected void handleLossBackwardCompatibility(BaseOutputLayer baseLayer, ObjectNode on){
    if(baseLayer.getLossFn() == null && on.has("activationFunction")) {
        String lfn = on.get("lossFunction").asText();
        ILossFunction loss = null;
        switch (lfn) {
            case "MCXENT":
                loss = new LossMCXENT();
                break;
            case "MSE":
                loss = new LossMSE();
                break;
            case "NEGATIVELOGLIKELIHOOD":
                loss = new LossNegativeLogLikelihood();
                break;
            case "SQUARED_LOSS":
                loss = new LossL2();
                break;
            case "XENT":
                loss = new LossBinaryXENT();
        }
        baseLayer.setLossFn(loss);
    }
}
 
Example #2
Source File: Dl4jMlpClassifier.java    From wekaDeeplearning4j with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks if the layer is a valid output layer
 * @param filterMode true if the model is being used for a filter
 * @param layer output layer of the model
 * @return true if the model doesn't have a valid output layer (we need to add one on)
 */
public static boolean noOutputLayer(boolean filterMode, org.deeplearning4j.nn.conf.layers.Layer layer) {
  return (!(filterMode) && !(layer instanceof BaseOutputLayer
          //|| layer instanceof LossLayer || layer instanceof ActivationLayer
          // The above two layers still throw errors from DL4j if they're the output
          ));
}
 
Example #3
Source File: Dl4jMlpClassifier.java    From wekaDeeplearning4j with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks if the layer is a valid output layer
 * @param filterMode true if the model is being used for a filter
 * @param layer output layer of the model
 * @return true if the model doesn't have a valid output layer (we need to add one on)
 */
public static boolean noOutputLayer(boolean filterMode, org.deeplearning4j.nn.conf.layers.Layer layer) {
  return (!(filterMode) && !(layer instanceof BaseOutputLayer
          //|| layer instanceof LossLayer || layer instanceof ActivationLayer
          // The above two layers still throw errors from DL4j if they're the output
          ));
}
 
Example #4
Source File: BaseNetConfigDeserializer.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
protected boolean requiresLegacyLossHandling(Layer[] layers){
    for(Layer l : layers){
        if(l instanceof BaseOutputLayer && ((BaseOutputLayer)l).getLossFn() == null){
            return true;
        }
    }
    return false;
}
 
Example #5
Source File: BaseOutputLayerSpace.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
protected void setLayerOptionsBuilder(BaseOutputLayer.Builder builder, double[] values) {
    super.setLayerOptionsBuilder(builder, values);
    if (lossFunction != null)
        builder.lossFunction(lossFunction.getValue(values));
    if (hasBias != null)
        builder.hasBias(hasBias.getValue(values));
}
 
Example #6
Source File: Dl4jMlpClassifier.java    From wekaDeeplearning4j with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Generate the, for this model type, typical output layer.
 *
 * @return New OutputLayer object
 */
protected Layer<? extends BaseOutputLayer> createOutputLayer() {
  return new OutputLayer();
}
 
Example #7
Source File: RnnSequenceClassifier.java    From wekaDeeplearning4j with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Generate the, for this model type, typical output layer.
 *
 * @return New OutputLayer object
 */
protected Layer<? extends BaseOutputLayer> createOutputLayer() {
  return new weka.dl4j.layers.RnnOutputLayer();
}
 
Example #8
Source File: Dl4jMlpClassifier.java    From wekaDeeplearning4j with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Generate the, for this model type, typical output layer.
 *
 * @return New OutputLayer object
 */
protected Layer<? extends BaseOutputLayer> createOutputLayer() {
  return new OutputLayer();
}
 
Example #9
Source File: RnnSequenceClassifier.java    From wekaDeeplearning4j with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Generate the, for this model type, typical output layer.
 *
 * @return New OutputLayer object
 */
protected Layer<? extends BaseOutputLayer> createOutputLayer() {
  return new weka.dl4j.layers.RnnOutputLayer();
}