labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1411569 - in /labs/yay/trunk/core/src: main/java/org/apache/yay/ main/java/org/apache/yay/neuron/ main/java/org/apache/yay/utils/ test/java/org/apache/yay/
Date Tue, 20 Nov 2012 07:32:38 GMT
Author: tommaso
Date: Tue Nov 20 07:32:37 2012
New Revision: 1411569

URL: http://svn.apache.org/viewvc?rev=1411569&view=rev
Log:
minor fixes: final modifiers, removed unnecessary (un)boxing, etc.

Modified:
    labs/yay/trunk/core/src/main/java/org/apache/yay/BackPropagationLearningStrategy.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/BasicPerceptron.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/NeuralNetworkFactory.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/StepActivationFunction.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/neuron/LinearNeuron.java
    labs/yay/trunk/core/src/main/java/org/apache/yay/utils/ConversionUtils.java
    labs/yay/trunk/core/src/test/java/org/apache/yay/BasicPerceptronTest.java

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/BackPropagationLearningStrategy.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/BackPropagationLearningStrategy.java?rev=1411569&r1=1411568&r2=1411569&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/BackPropagationLearningStrategy.java
(original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/BackPropagationLearningStrategy.java
Tue Nov 20 07:32:37 2012
@@ -32,7 +32,7 @@ import org.apache.yay.utils.ConversionUt
  */
 public class BackPropagationLearningStrategy implements LearningStrategy<Double, Double[]>
{
 
-  private PredictionStrategy<Double, Double[]> predictionStrategy;
+  private final PredictionStrategy<Double, Double[]> predictionStrategy;
 
   public BackPropagationLearningStrategy(PredictionStrategy<Double, Double[]> predictionStrategy)
{
     this.predictionStrategy = predictionStrategy;

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/BasicPerceptron.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/BasicPerceptron.java?rev=1411569&r1=1411568&r2=1411569&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/BasicPerceptron.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/BasicPerceptron.java Tue Nov 20 07:32:37
2012
@@ -28,9 +28,9 @@ import org.apache.yay.utils.ConversionUt
  */
 public class BasicPerceptron implements NeuralNetwork<Double, Double> {
 
-    private BinaryThresholdNeuron perceptronNeuron;
+    private final BinaryThresholdNeuron perceptronNeuron;
 
-    private double[] currentWeights;
+    private final double[] currentWeights;
 
     /**
      * Create a perceptron given its input weights.

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/NeuralNetworkFactory.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/NeuralNetworkFactory.java?rev=1411569&r1=1411568&r2=1411569&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/NeuralNetworkFactory.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/NeuralNetworkFactory.java Tue Nov 20
07:32:37 2012
@@ -41,8 +41,8 @@ public class NeuralNetworkFactory {
    */
   public static NeuralNetwork<Double, Double> create(final Collection<TrainingExample<Double,
Double>> trainingExamples,
                                                      final WeightsMatrix[] weightsMatrixSet,
final LearningStrategy<Double, Double> learningStrategy,
-                                                     final PredictionStrategy<Double,
Double> predictionStrategy) throws CreationException {
-    NeuralNetwork<Double, Double> neuralNetwork = new NeuralNetwork<Double, Double>()
{
+                                                     final PredictionStrategy<Double,
Double> predictionStrategy) {
+    return new NeuralNetwork<Double, Double>() {
 
       private WeightsMatrix[] updatedWeightsMatrixSet = weightsMatrixSet;
 
@@ -65,8 +65,6 @@ public class NeuralNetworkFactory {
         }
       }
     };
-
-    return neuralNetwork;
   }
 
 }

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/StepActivationFunction.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/StepActivationFunction.java?rev=1411569&r1=1411568&r2=1411569&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/StepActivationFunction.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/StepActivationFunction.java Tue Nov 20
07:32:37 2012
@@ -23,7 +23,7 @@ package org.apache.yay;
  */
 public class StepActivationFunction implements ActivationFunction<Double> {
 
-    private double center;
+    private final double center;
 
     public StepActivationFunction(double center) {
         this.center = center;

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/neuron/LinearNeuron.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/neuron/LinearNeuron.java?rev=1411569&r1=1411568&r2=1411569&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/neuron/LinearNeuron.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/neuron/LinearNeuron.java Tue Nov 20 07:32:37
2012
@@ -27,7 +27,7 @@ import org.apache.yay.IdentityActivation
 public class LinearNeuron extends BasicElaborationUnit<Double> {
 
     private final double[] weights;
-    private Double bias;
+    private final Double bias;
 
     public LinearNeuron(Double bias, double... weights) {
         this.activationFunction = new IdentityActivationFunction<Double>();

Modified: labs/yay/trunk/core/src/main/java/org/apache/yay/utils/ConversionUtils.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/main/java/org/apache/yay/utils/ConversionUtils.java?rev=1411569&r1=1411568&r2=1411569&view=diff
==============================================================================
--- labs/yay/trunk/core/src/main/java/org/apache/yay/utils/ConversionUtils.java (original)
+++ labs/yay/trunk/core/src/main/java/org/apache/yay/utils/ConversionUtils.java Tue Nov 20
07:32:37 2012
@@ -60,7 +60,7 @@ public class ConversionUtils {
     double[] ar = new double[sample.getFeatureVector().size()];
     int i = 0;
     for (Feature<Double> f : sample.getFeatureVector()) {
-      ar[i] = f.getValue().doubleValue();
+      ar[i] = f.getValue();
       i++;
     }
     return ar;
@@ -97,7 +97,7 @@ public class ConversionUtils {
   public static Double[] toDoubleArray(double[] ar) {
     Double[] doubles = new Double[ar.length];
     for (int i = 0; i < ar.length; i++) {
-      doubles[i] = Double.valueOf(ar[i]);
+      doubles[i] = ar[i];
     }
     return doubles;
   }

Modified: labs/yay/trunk/core/src/test/java/org/apache/yay/BasicPerceptronTest.java
URL: http://svn.apache.org/viewvc/labs/yay/trunk/core/src/test/java/org/apache/yay/BasicPerceptronTest.java?rev=1411569&r1=1411568&r2=1411569&view=diff
==============================================================================
--- labs/yay/trunk/core/src/test/java/org/apache/yay/BasicPerceptronTest.java (original)
+++ labs/yay/trunk/core/src/test/java/org/apache/yay/BasicPerceptronTest.java Tue Nov 20 07:32:37
2012
@@ -45,7 +45,7 @@ public class BasicPerceptronTest {
                 createTrainingExample(1d, 5d, 6d, 0.5d),
                 createTrainingExample(0.1d, 9d, 4d, 1.9d),
                 createTrainingExample(0.11d, 4d, 2.6d, 9.5d));
-        Double output = basicPerceptron.predict(createTrainingExample(0d, 1d, 6d, 0.4d));
+        Double output = basicPerceptron.predict(createTrainingExample(null, 1d, 6d, 0.4d));
         assertEquals(Double.valueOf(1d), output);
     }
 



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


Mime
View raw message