All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dmg.pmml.neural_network.NeuralLayer Maven / Gradle / Ivy

There is a newer version: 1.6.5
Show newest version

package org.dmg.pmml.neural_network;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.dmg.pmml.Extension;
import org.dmg.pmml.HasExtensions;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.dmg.pmml.adapters.NonNegativeIntegerAdapter;
import org.dmg.pmml.adapters.RealNumberAdapter;
import org.dmg.pmml.neural_network.NeuralNetwork.ActivationFunction;
import org.dmg.pmml.neural_network.NeuralNetwork.NormalizationMethod;
import org.jpmml.model.annotations.ValueConstructor;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "extensions",
    "neurons"
})
@XmlRootElement(name = "NeuralLayer", namespace = "http://www.dmg.org/PMML-4_3")
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonPropertyOrder({
    "numberOfNeurons",
    "activationFunction",
    "threshold",
    "width",
    "altitude",
    "normalizationMethod",
    "extensions",
    "neurons"
})
public class NeuralLayer
    extends org.dmg.pmml.PMMLObject
    implements HasExtensions
{

    @XmlAttribute(name = "numberOfNeurons")
    @XmlJavaTypeAdapter(NonNegativeIntegerAdapter.class)
    @XmlSchemaType(name = "nonNegativeInteger")
    @JsonProperty("numberOfNeurons")
    private Integer numberOfNeurons;
    @XmlAttribute(name = "activationFunction")
    @JsonProperty("activationFunction")
    private ActivationFunction activationFunction;
    @XmlAttribute(name = "threshold")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @JsonProperty("threshold")
    private Number threshold;
    @XmlAttribute(name = "width")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @JsonProperty("width")
    private Number width;
    @XmlAttribute(name = "altitude")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @JsonProperty("altitude")
    private Number altitude;
    @XmlAttribute(name = "normalizationMethod")
    @JsonProperty("normalizationMethod")
    private NormalizationMethod normalizationMethod;
    @XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_3")
    @JsonProperty("Extension")
    private List extensions;
    @XmlElement(name = "Neuron", namespace = "http://www.dmg.org/PMML-4_3", required = true)
    @JsonProperty("Neuron")
    private List neurons;
    private final static long serialVersionUID = 67305489L;

    public NeuralLayer() {
    }

    @ValueConstructor
    public NeuralLayer(
        @org.jpmml.model.annotations.Property("neurons")
        List neurons) {
        this.neurons = neurons;
    }

    public Integer getNumberOfNeurons() {
        return numberOfNeurons;
    }

    public NeuralLayer setNumberOfNeurons(
        @org.jpmml.model.annotations.Property("numberOfNeurons")
        Integer numberOfNeurons) {
        this.numberOfNeurons = numberOfNeurons;
        return this;
    }

    public ActivationFunction getActivationFunction() {
        return activationFunction;
    }

    public NeuralLayer setActivationFunction(
        @org.jpmml.model.annotations.Property("activationFunction")
        ActivationFunction activationFunction) {
        this.activationFunction = activationFunction;
        return this;
    }

    public Number getThreshold() {
        return threshold;
    }

    public NeuralLayer setThreshold(
        @org.jpmml.model.annotations.Property("threshold")
        Number threshold) {
        this.threshold = threshold;
        return this;
    }

    public Number getWidth() {
        return width;
    }

    public NeuralLayer setWidth(
        @org.jpmml.model.annotations.Property("width")
        Number width) {
        this.width = width;
        return this;
    }

    public Number getAltitude() {
        return altitude;
    }

    public NeuralLayer setAltitude(
        @org.jpmml.model.annotations.Property("altitude")
        Number altitude) {
        this.altitude = altitude;
        return this;
    }

    public NormalizationMethod getNormalizationMethod() {
        return normalizationMethod;
    }

    public NeuralLayer setNormalizationMethod(
        @org.jpmml.model.annotations.Property("normalizationMethod")
        NormalizationMethod normalizationMethod) {
        this.normalizationMethod = normalizationMethod;
        return this;
    }

    @Override
    public boolean hasExtensions() {
        return ((this.extensions!= null)&&(this.extensions.size()> 0));
    }

    @Override
    public List getExtensions() {
        if (extensions == null) {
            extensions = new ArrayList();
        }
        return this.extensions;
    }

    @Override
    public NeuralLayer addExtensions(Extension... extensions) {
        getExtensions().addAll(Arrays.asList(extensions));
        return this;
    }

    public boolean hasNeurons() {
        return ((this.neurons!= null)&&(this.neurons.size()> 0));
    }

    public List getNeurons() {
        if (neurons == null) {
            neurons = new ArrayList();
        }
        return this.neurons;
    }

    public NeuralLayer addNeurons(Neuron... neurons) {
        getNeurons().addAll(Arrays.asList(neurons));
        return this;
    }

    @Override
    public VisitorAction accept(Visitor visitor) {
        VisitorAction status = visitor.visit(this);
        if (status == VisitorAction.CONTINUE) {
            visitor.pushParent(this);
            if ((status == VisitorAction.CONTINUE)&&hasExtensions()) {
                status = org.dmg.pmml.PMMLObject.traverse(visitor, getExtensions());
            }
            if ((status == VisitorAction.CONTINUE)&&hasNeurons()) {
                status = org.dmg.pmml.PMMLObject.traverse(visitor, getNeurons());
            }
            visitor.popParent();
        }
        if (status == VisitorAction.TERMINATE) {
            return VisitorAction.TERMINATE;
        }
        return VisitorAction.CONTINUE;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy