labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1706900 - in /labs/yay/trunk: api/src/main/java/org/apache/yay/ core/src/main/java/org/apache/yay/core/ core/src/main/java/org/apache/yay/core/neuron/ core/src/main/java/org/apache/yay/core/utils/
Date Mon, 05 Oct 2015 19:19:53 GMT
Author: tommaso
Date: Mon Oct  5 19:19:52 2015
New Revision: 1706900

URL: http://svn.apache.org/viewvc?rev=1706900&view=rev
Log:
minor fixes suggested by static analysis

Modified:
    labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java
    labs/yay/trunk/api/src/main/java/org/apache/yay/InvalidWeightMatrixException.java
    labs/yay/trunk/api/src/main/java/org/apache/yay/TrainingSet.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/BackPropagationLearningStrategy.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/DefaultDerivativeUpdateFunction.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/LMSCostFunction.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/LogisticRegressionCostFunction.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/MaxSelectionFunction.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/NeuralNetworkFactory.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/LinearNeuron.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/RectifiedLinearNeuron.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/SigmoidNeuron.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ConversionUtils.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ExamplesFactory.java

Modified: labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java (original)
+++ labs/yay/trunk/api/src/main/java/org/apache/yay/Hypothesis.java Mon Oct  5 19:19:52 2015
@@ -18,8 +18,6 @@
  */
 package org.apache.yay;
 
-import java.util.List;
-
 /**
  * In machine learning an hypothesis is the output of applying a learning
  * algorithm to a training set, an hypothesis maps new inputs to possible outputs.

Modified: labs/yay/trunk/api/src/main/java/org/apache/yay/InvalidWeightMatrixException.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/api/src/main/java/org/apache/yay/InvalidWeightMatrixException.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/api/src/main/java/org/apache/yay/InvalidWeightMatrixException.java (original)
+++ labs/yay/trunk/api/src/main/java/org/apache/yay/InvalidWeightMatrixException.java Mon
Oct  5 19:19:52 2015
@@ -22,5 +22,5 @@ package org.apache.yay;
  * {@link Exception} thrown when a {@link org.apache.commons.math3.linear.RealMatrix} is
verified to be invalid
  */
 @SuppressWarnings("serial")
-public class InvalidWeightMatrixException extends Exception {
+class InvalidWeightMatrixException extends Exception {
 }

Modified: labs/yay/trunk/api/src/main/java/org/apache/yay/TrainingSet.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/api/src/main/java/org/apache/yay/TrainingSet.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/api/src/main/java/org/apache/yay/TrainingSet.java (original)
+++ labs/yay/trunk/api/src/main/java/org/apache/yay/TrainingSet.java Mon Oct  5 19:19:52 2015
@@ -26,7 +26,7 @@ import java.util.Iterator;
  */
 public class TrainingSet<F, O> implements Iterable<TrainingExample<F, O>>
{
 
-  private Collection<TrainingExample<F, O>> samples;
+  private final Collection<TrainingExample<F, O>> samples;
 
   public TrainingSet(Collection<TrainingExample<F, O>> samples) {
     this.samples = samples;

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/BackPropagationLearningStrategy.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/BackPropagationLearningStrategy.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/BackPropagationLearningStrategy.java
(original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/BackPropagationLearningStrategy.java
Mon Oct  5 19:19:52 2015
@@ -39,7 +39,7 @@ import org.apache.yay.WeightLearningExce
 public class BackPropagationLearningStrategy implements LearningStrategy<Double, Double>
{
 
   public static final double DEFAULT_THRESHOLD = 0.05;
-  public static final int MAX_ITERATIONS = 100000;
+  private static final int MAX_ITERATIONS = 100000;
   public static final double DEFAULT_ALPHA = 0.000003;
 
   private final PredictionStrategy<Double, Double> predictionStrategy;

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/DefaultDerivativeUpdateFunction.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/DefaultDerivativeUpdateFunction.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/DefaultDerivativeUpdateFunction.java
(original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/DefaultDerivativeUpdateFunction.java
Mon Oct  5 19:19:52 2015
@@ -30,7 +30,7 @@ import org.apache.yay.core.utils.Convers
 /**
  * Default derivatives update function
  */
-public class DefaultDerivativeUpdateFunction implements DerivativeUpdateFunction<Double,
Double> {
+class DefaultDerivativeUpdateFunction implements DerivativeUpdateFunction<Double, Double>
{
 
   private final PredictionStrategy<Double, Double> predictionStrategy;
 

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/LMSCostFunction.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/LMSCostFunction.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/LMSCostFunction.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/LMSCostFunction.java Mon Oct  5
19:19:52 2015
@@ -27,7 +27,7 @@ import org.apache.yay.TrainingSet;
 /**
  * Least mean square cost function
  */
-public class LMSCostFunction implements NeuralNetworkCostFunction {
+class LMSCostFunction implements NeuralNetworkCostFunction {
     @Override
     public Double calculateAggregatedCost(TrainingSet<Double, Double> trainingExamples,
Hypothesis<RealMatrix, Double, Double> hypothesis) throws Exception {
         TrainingExample<Double, Double>[] samples = new TrainingExample[trainingExamples.size()];

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/LogisticRegressionCostFunction.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/LogisticRegressionCostFunction.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/LogisticRegressionCostFunction.java
(original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/LogisticRegressionCostFunction.java
Mon Oct  5 19:19:52 2015
@@ -70,7 +70,7 @@ public class LogisticRegressionCostFunct
   }
 
   private Double calculateErrorTerm(Hypothesis<RealMatrix, Double, Double> hypothesis,
-                                    TrainingExample<Double, Double>... trainingExamples)
throws PredictionException, CreationException {
+                                    TrainingExample<Double, Double>... trainingExamples)
throws PredictionException {
     Double res = 0d;
 
     for (TrainingExample<Double, Double> input : trainingExamples) {

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/MaxSelectionFunction.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/MaxSelectionFunction.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/MaxSelectionFunction.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/MaxSelectionFunction.java Mon Oct
 5 19:19:52 2015
@@ -25,7 +25,7 @@ import org.apache.yay.SelectionFunction;
 /**
  * Selects the max value from a {@link Collection} of {@link Comparable} outputs.
  */
-public class MaxSelectionFunction<T extends Comparable<T>> implements SelectionFunction<Collection<T>,
T> {
+class MaxSelectionFunction<T extends Comparable<T>> implements SelectionFunction<Collection<T>,
T> {
 
   @Override
   public T selectOutput(Collection<T> neuralNetworkOutput) {

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/NeuralNetworkFactory.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/NeuralNetworkFactory.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/NeuralNetworkFactory.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/NeuralNetworkFactory.java Mon Oct
 5 19:19:52 2015
@@ -47,10 +47,10 @@ public class NeuralNetworkFactory {
    * @throws org.apache.yay.CreationException
    */
   public static NeuralNetwork create(final RealMatrix[] realMatrixSet, final LearningStrategy<Double,
Double> learningStrategy,
-                                     final PredictionStrategy<Double, Double> predictionStrategy)
throws CreationException {
+                                     final PredictionStrategy<Double, Double> predictionStrategy)
{
     return new NeuralNetwork() {
 
-      private Double[] getOutputVector(Input<Double> input) throws PredictionException
{
+      private Double[] getOutputVector(Input<Double> input) {
         Collection<Double> inputVector = ConversionUtils.toValuesCollection(input.getFeatures());
         return predictionStrategy.predictOutput(inputVector, updatedRealMatrixSet);
       }

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/LinearNeuron.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/LinearNeuron.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/LinearNeuron.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/LinearNeuron.java Mon Oct
 5 19:19:52 2015
@@ -24,13 +24,13 @@ import org.apache.yay.core.IdentityActiv
 /**
  * A neuron doing linear combination of inputs
  */
-public class LinearNeuron extends Neuron<Double> {
+class LinearNeuron extends Neuron<Double> {
 
   private final Double[] weights;
 
   private final Double bias;
 
-  public LinearNeuron(Double bias, Double... weights) {
+  LinearNeuron(Double bias, Double... weights) {
     super(new IdentityActivationFunction<Double>());
     this.bias = bias;
     this.weights = weights;

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/RectifiedLinearNeuron.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/RectifiedLinearNeuron.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/RectifiedLinearNeuron.java
(original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/RectifiedLinearNeuron.java
Mon Oct  5 19:19:52 2015
@@ -24,7 +24,7 @@ import org.apache.yay.ActivationFunction
  * A rectified linear neuron which is similar to {@link LinearNeuron} but cuts all the negative
  * outputs to 0
  */
-public class RectifiedLinearNeuron extends LinearNeuron {
+class RectifiedLinearNeuron extends LinearNeuron {
 
   public RectifiedLinearNeuron(Double bias, Double... weights) {
     super(bias, weights);

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/SigmoidNeuron.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/SigmoidNeuron.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/SigmoidNeuron.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/neuron/SigmoidNeuron.java Mon Oct
 5 19:19:52 2015
@@ -23,7 +23,7 @@ import org.apache.yay.core.SigmoidFuncti
 /**
  * A linear neuron whose output is smoothed via a {@link SigmoidFunction}
  */
-public class SigmoidNeuron extends LinearNeuron {
+class SigmoidNeuron extends LinearNeuron {
 
   public SigmoidNeuron(Double bias, Double... weights) {
     super(bias, weights);

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ConversionUtils.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ConversionUtils.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ConversionUtils.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ConversionUtils.java Mon Oct
 5 19:19:52 2015
@@ -84,7 +84,7 @@ public class ConversionUtils {
    * @param featureVector the vector of features
    * @return a vector of Doubles
    */
-  public static <T extends Object> Collection<T> toValuesCollection(Collection<Feature<T>>
featureVector) {
+  public static <T> Collection<T> toValuesCollection(Collection<Feature<T>>
featureVector) {
     // TODO : remove this and change APIs in a way that doesn't force to go through this
ugly loop
     Collection<T> resultVector = new ArrayList<T>();
     for (Feature<T> feature : featureVector) {

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ExamplesFactory.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ExamplesFactory.java?rev=1706900&r1=1706899&r2=1706900&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ExamplesFactory.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/core/utils/ExamplesFactory.java Mon Oct
 5 19:19:52 2015
@@ -19,7 +19,6 @@
 package org.apache.yay.core.utils;
 
 import java.util.ArrayList;
-import java.util.Collection;
 
 import org.apache.yay.Feature;
 import org.apache.yay.Input;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message