/*-
 *
 *  * Copyright 2017 Skymind,Inc.
 *  *
 *  *    Licensed under the Apache License, Version 2.0 (the "License");
 *  *    you may not use this file except in compliance with the License.
 *  *    You may obtain a copy of the License at
 *  *
 *  *        http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *    Unless required by applicable law or agreed to in writing, software
 *  *    distributed under the License is distributed on an "AS IS" BASIS,
 *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *    See the License for the specific language governing permissions and
 *  *    limitations under the License.
 *
 */
package org.deeplearning4j.nn.modelimport.keras.layers.advanced.activations;

import org.deeplearning4j.nn.conf.inputs.InputType;
import org.deeplearning4j.nn.conf.layers.ActivationLayer;
import org.deeplearning4j.nn.modelimport.keras.InvalidKerasConfigurationException;
import org.deeplearning4j.nn.modelimport.keras.KerasLayer;
import org.deeplearning4j.nn.modelimport.keras.UnsupportedKerasConfigurationException;
import org.nd4j.linalg.activations.IActivation;
import org.nd4j.linalg.activations.impl.ActivationLReLU;


import java.util.Map;

/**
 * Imports LeakyReLU layer from Keras
 *
 * @author Max Pumperla
 */
public class KerasLeakyReLU  extends KerasLayer {

    /* Keras layer parameter names. */
    public static final String LAYER_FIELD_LEAKY_RELU_ALPHA = "alpha";


    /**
     * Constructor from parsed Keras layer configuration dictionary.
     *
     * @param layerConfig   dictionary containing Keras layer configuration
     * @throws InvalidKerasConfigurationException
     * @throws UnsupportedKerasConfigurationException
     */
    public KerasLeakyReLU(Map<String, Object> layerConfig)
            throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException {
        this(layerConfig, true);
    }

    /**
     * Constructor from parsed Keras layer configuration dictionary.
     *
     * @param layerConfig               dictionary containing Keras layer configuration
     * @param enforceTrainingConfig     whether to enforce training-related configuration options
     * @throws InvalidKerasConfigurationException
     * @throws UnsupportedKerasConfigurationException
     */
    public KerasLeakyReLU(Map<String, Object> layerConfig, boolean enforceTrainingConfig)
            throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException {
        super(layerConfig, enforceTrainingConfig);
        Map<String, Object> innerConfig = getInnerLayerConfigFromConfig(layerConfig);
        // Set default alpha to default in nd4j
        double alpha = 0.01;
        if (innerConfig.containsKey(LAYER_FIELD_LEAKY_RELU_ALPHA)) {
            alpha = (double) innerConfig.get(LAYER_FIELD_LEAKY_RELU_ALPHA);
        }
        IActivation leakyReLU = new ActivationLReLU(alpha);
        this.layer = new ActivationLayer.Builder().name(this.layerName).activation(leakyReLU).build();
    }

    /**
     * Get layer output type.
     *
     * @param  inputType    Array of InputTypes
     * @return              output type as InputType
     * @throws InvalidKerasConfigurationException
     */
    public InputType getOutputType(InputType... inputType) throws InvalidKerasConfigurationException {
        if (inputType.length > 1)
            throw new InvalidKerasConfigurationException(
                    "Keras Activation layer accepts only one input (received " + inputType.length + ")");
        return this.getActivationLayer().getOutputType(-1, inputType[0]);
    }

    /**
     * Get DL4J ActivationLayer.
     *
     * @return  ActivationLayer
     */
    public ActivationLayer getActivationLayer() {
        return (ActivationLayer) this.layer;
    }

//    public ActivationLReLU(double alpha) {
//        this.alpha = alpha;
//    }

}

@@ -1310,17 +1310,16 @@
 akyReLU 
- 
 extends 
@@ -1331,16 +1331,16 @@
 Layer %7B%0A
+
 %0A    /* 
@@ -1554,18 +1554,16 @@
 rConfig 
-  
 dictiona
@@ -2029,20 +2029,16 @@
         
-    
 dictiona
@@ -2113,20 +2113,16 @@
 gConfig 
-    
 whether 
@@ -3067,17 +3067,16 @@
  @param 
- 
 inputTyp
@@ -3077,19 +3077,16 @@
 putType 
-   
 Array of
@@ -3112,29 +3112,16 @@
 @return 
-             
 output t
@@ -3640,17 +3640,16 @@
 @return 
- 
 Activati
@@ -3770,90 +3770,6 @@
  %7D%0A%0A
-//    public ActivationLReLU(double alpha) %7B%0A//        this.alpha = alpha;%0A//    %7D%0A%0A
 %7D%0A

clean up