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.6
Show newest version

package org.dmg.pmml.neural_network;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSchemaType;
import jakarta.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
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.MissingElementException;
import org.jpmml.model.annotations.Added;
import org.jpmml.model.annotations.CollectionSize;
import org.jpmml.model.annotations.ValueConstructor;

@XmlRootElement(name = "NeuralLayer", namespace = "http://www.dmg.org/PMML-4_4")
@XmlType(name = "", propOrder = {
    "extensions",
    "neurons"
})
@JsonRootName("NeuralLayer")
@JsonPropertyOrder({
    "numberOfNeurons",
    "activationFunction",
    "threshold",
    "leakage",
    "width",
    "altitude",
    "normalizationMethod",
    "extensions",
    "neurons"
})
public class NeuralLayer
    extends org.dmg.pmml.PMMLObject
    implements HasExtensions , HasActivationFunction , HasNormalizationMethod
{

    @XmlAttribute(name = "numberOfNeurons")
    @XmlJavaTypeAdapter(NonNegativeIntegerAdapter.class)
    @XmlSchemaType(name = "nonNegativeInteger")
    @CollectionSize(("neurons"))
    @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 = "x-leakage")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @Added((org.dmg.pmml.Version.XPMML))
    @JsonProperty("x-leakage")
    private Number leakage;
    @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_4")
    @JsonProperty("Extension")
    private List extensions;
    @XmlElement(name = "Neuron", namespace = "http://www.dmg.org/PMML-4_4", required = true)
    @JsonProperty("Neuron")
    private List neurons;
    private final static long serialVersionUID = 67371270L;

    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;
    }

    @Override
    public ActivationFunction getActivationFunction() {
        return activationFunction;
    }

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

    @Override
    public Number getThreshold() {
        return threshold;
    }

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

    @Override
    public Number getLeakage() {
        return leakage;
    }

    @Override
    public NeuralLayer setLeakage(
        @org.jpmml.model.annotations.Property("leakage")
        Number leakage) {
        this.leakage = leakage;
        return this;
    }

    @Override
    public Number getWidth() {
        return width;
    }

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

    @Override
    public Number getAltitude() {
        return altitude;
    }

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

    @Override
    public NormalizationMethod getNormalizationMethod() {
        return normalizationMethod;
    }

    @Override
    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.isEmpty()));
    }

    @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.isEmpty()));
    }

    public List requireNeurons() {
        if ((this.neurons == null)||this.neurons.isEmpty()) {
            throw new MissingElementException(this, PMMLElements.NEURALLAYER_NEURONS);
        }
        return this.neurons;
    }

    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