Repository: ignite Updated Branches: refs/heads/master 5e5768f1d -> 7ac2d4ddb
IGNITE-9124: Remove some dead code in math.exceptions and optimization packages of ML module this closes #4462 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7ac2d4dd Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7ac2d4dd Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7ac2d4dd Branch: refs/heads/master Commit: 7ac2d4ddb885592a72e0875aac57dad365ffc3b6 Parents: 5e5768f Author: Oleg Ignatenko <[email protected]> Authored: Wed Aug 8 15:20:36 2018 +0300 Committer: Yury Babak <[email protected]> Committed: Wed Aug 8 15:20:36 2018 +0300 ---------------------------------------------------------------------- .../math/exceptions/ConvergenceException.java | 47 ------------ .../exceptions/InsufficientDataException.java | 44 ----------- .../exceptions/MathIllegalNumberException.java | 51 ------------- .../exceptions/MathIllegalStateException.java | 49 ------------ .../NonPositiveDefiniteMatrixException.java | 35 --------- .../exceptions/NonSymmetricMatrixException.java | 35 --------- .../math/exceptions/NullArgumentException.java | 27 ------- .../exceptions/NumberIsTooSmallException.java | 79 -------------------- .../exceptions/SingularMatrixException.java | 33 -------- .../exceptions/UnknownProviderException.java | 35 --------- .../ml/optimization/BarzilaiBorweinUpdater.java | 55 -------------- .../ignite/ml/optimization/SimpleUpdater.java | 46 ------------ .../apache/ignite/ml/optimization/Updater.java | 30 -------- .../ml/structures/LabeledVectorDouble.java | 46 ------------ 14 files changed, 612 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ConvergenceException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ConvergenceException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ConvergenceException.java deleted file mode 100644 index 64687b6..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ConvergenceException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -/** - * This class is based on the corresponding class from Apache Common Math lib. - * Error thrown when a numerical computation can not be performed because the - * numerical result failed to converge to a finite value. - */ -public class ConvergenceException extends MathIllegalStateException { - /** Serializable version Id. */ - private static final long serialVersionUID = 4330003017885151975L; - - /** */ - private static final String CONVERGENCE_FAILED = "convergence failed"; - - /** - * Construct the exception. - */ - public ConvergenceException() { - this(CONVERGENCE_FAILED); - } - - /** - * Construct the exception with a specific context and arguments. - * - * @param msg Message pattern providing the specific context of the error. - * @param args Arguments. - */ - public ConvergenceException(String msg, Object... args) { - super(msg, args); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/InsufficientDataException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/InsufficientDataException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/InsufficientDataException.java deleted file mode 100644 index a57997d..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/InsufficientDataException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -/** - * This class is based on the corresponding class from Apache Common Math lib. - * Exception to be thrown when there is insufficient data to perform a computation. - */ -public class InsufficientDataException extends MathIllegalArgumentException { - /** Serializable version Id. */ - private static final long serialVersionUID = -2629324471511903359L; - - /** */ - private static final String INSUFFICIENT_DATA = "Insufficient data."; - - /** - * Construct the exception. - */ - public InsufficientDataException() { - this(INSUFFICIENT_DATA); - } - - /** - * Construct the exception. - */ - public InsufficientDataException(String msg, Object... args) { - super(msg, args); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalNumberException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalNumberException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalNumberException.java deleted file mode 100644 index b2abf63..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalNumberException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -/** - * This class is based on the corresponding class from Apache Common Math lib. - * Base class for exceptions raised by a wrong number. - * This class is not intended to be instantiated directly: it should serve - * as a base class to create all the exceptions that are raised because some - * precondition is violated by a number argument. - */ -public class MathIllegalNumberException extends MathIllegalArgumentException { - /** Serializable version Id. */ - private static final long serialVersionUID = -7447085893598031110L; - - /** Requested. */ - private final Number arg; - - /** - * Construct an exception. - * - * @param msg Localizable pattern. - * @param wrong Wrong number. - * @param arguments Arguments. - */ - protected MathIllegalNumberException(String msg, Number wrong, Object... arguments) { - super(msg, wrong, arguments); - arg = wrong; - } - - /** - * @return the requested value. - */ - public Number getArg() { - return arg; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalStateException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalStateException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalStateException.java deleted file mode 100644 index 6c63086..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalStateException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -/** - * This class is based on the corresponding class from Apache Common Math lib. - * Base class for all exceptions that signal that the process - * throwing the exception is in a state that does not comply with - * the set of states that it is designed to be in. - */ -public class MathIllegalStateException extends MathRuntimeException { - /** Serializable version Id. */ - private static final long serialVersionUID = -6024911025449780478L; - - /** */ - private static final String ILLEGAL_STATE = "Illegal state."; - - /** - * Simple constructor. - * - * @param msg Message pattern explaining the cause of the error. - * @param args Arguments. - */ - public MathIllegalStateException(String msg, Object... args) { - super(msg, args); - } - - /** - * Default constructor. - */ - public MathIllegalStateException() { - this(ILLEGAL_STATE); - } - -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonPositiveDefiniteMatrixException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonPositiveDefiniteMatrixException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonPositiveDefiniteMatrixException.java deleted file mode 100644 index 2e588dc..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonPositiveDefiniteMatrixException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -/** - * This exception is used to indicate error condition of matrix elements failing the positivity check. - */ -public class NonPositiveDefiniteMatrixException extends MathIllegalArgumentException { - /** - * Construct an exception. - * - * @param wrong Value that fails the positivity check. - * @param idx Row (and column) index. - * @param threshold Absolute positivity threshold. - */ - public NonPositiveDefiniteMatrixException(double wrong, int idx, double threshold) { - super("Matrix must be positive, wrong element located on diagonal with index %d and has value %f with this threshold %f", - idx, wrong, threshold); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonSymmetricMatrixException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonSymmetricMatrixException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonSymmetricMatrixException.java deleted file mode 100644 index 7c563fe..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NonSymmetricMatrixException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -import org.apache.ignite.IgniteException; - -/** - * This exception is used to indicate error condition of matrix failing the symmetry check. - */ -public class NonSymmetricMatrixException extends IgniteException { - /** - * @param row Row. - * @param col Column. - * @param threshold Threshold. - */ - public NonSymmetricMatrixException(int row, int col, double threshold) { - super("Symmetric matrix expected, the symmetry is broken on row " - + row + " and col " + col + " with this threshold " + threshold); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NullArgumentException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NullArgumentException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NullArgumentException.java deleted file mode 100644 index 58a6fa3..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NullArgumentException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -/** - * This class is based on the corresponding class from Apache Common Math lib. - * All conditions checks that fail due to a {@code null} argument must throw - * this exception. - * This class is meant to signal a precondition violation ("null is an illegal - * argument"). - */ -public class NullArgumentException extends NullPointerException { -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NumberIsTooSmallException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NumberIsTooSmallException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NumberIsTooSmallException.java deleted file mode 100644 index 7427592..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/NumberIsTooSmallException.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -/** - * Exception to be thrown when a number is too small. - */ -public class NumberIsTooSmallException extends MathIllegalNumberException { - /** */ - private static final String NUMBER_TOO_SMALL = "Number {1} is smaller than the minimum ({2})."; - - /** */ - private static final String NUMBER_TOO_SMALL_BOUND_EXCLUDED = "Number {1} is smaller than, or equal to, the minimum ({2})."; - - /** Serializable version Id. */ - private static final long serialVersionUID = -6100997100383932834L; - /** - * Higher bound. - */ - private final Number min; - /** - * Whether the maximum is included in the allowed range. - */ - private final boolean boundIsAllowed; - - /** - * Construct the exception. - * - * @param wrong Value that is smaller than the minimum. - * @param min Minimum. - * @param boundIsAllowed Whether {@code min} is included in the allowed range. - */ - public NumberIsTooSmallException(Number wrong, Number min, boolean boundIsAllowed) { - this(boundIsAllowed ? NUMBER_TOO_SMALL : NUMBER_TOO_SMALL_BOUND_EXCLUDED, - wrong, min, boundIsAllowed); - } - - /** - * Construct the exception with a specific context. - * - * @param msg Specific context pattern. - * @param wrong Value that is smaller than the minimum. - * @param min Minimum. - * @param boundIsAllowed Whether {@code min} is included in the allowed range. - */ - public NumberIsTooSmallException(String msg, Number wrong, Number min, boolean boundIsAllowed) { - super(msg, wrong, min); - this.min = min; - this.boundIsAllowed = boundIsAllowed; - } - - /** - * @return {@code true} if the minimum is included in the allowed range. - */ - public boolean getBoundIsAllowed() { - return boundIsAllowed; - } - - /** - * @return the minimum. - */ - public Number getMin() { - return min; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/SingularMatrixException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/SingularMatrixException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/SingularMatrixException.java deleted file mode 100644 index c7acc80..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/SingularMatrixException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -/** - * Exception to be thrown when a non-singular matrix is expected. - */ -public class SingularMatrixException extends MathIllegalArgumentException { - /** */ - public SingularMatrixException() { - super("Regular (or non-singular) matrix expected."); - } - - /** */ - public SingularMatrixException(String format, Object... args) { - super(format, args); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnknownProviderException.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnknownProviderException.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnknownProviderException.java deleted file mode 100644 index 940b9aa..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/UnknownProviderException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.math.exceptions; - -import org.apache.ignite.IgniteException; - -/** - * Indicates that no provider has been found for a given vector or matrix flavor. - */ -public class UnknownProviderException extends IgniteException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param flv Flavor (a.k.a. operation performance hints) that has no registered provider for. - */ - public UnknownProviderException(String flv) { - super("No provider has been found for the flavor: " + flv); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/optimization/BarzilaiBorweinUpdater.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/optimization/BarzilaiBorweinUpdater.java b/modules/ml/src/main/java/org/apache/ignite/ml/optimization/BarzilaiBorweinUpdater.java deleted file mode 100644 index c374a8a..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/optimization/BarzilaiBorweinUpdater.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.optimization; - -import org.apache.ignite.ml.math.primitives.vector.Vector; - -/** - * Updater based in Barzilai-Borwein method which guarantees convergence. - */ -public class BarzilaiBorweinUpdater implements Updater { - /** */ - private static final long serialVersionUID = 5046575099408708472L; - - /** - * Learning rate used on the first iteration. - */ - private static final double INITIAL_LEARNING_RATE = 1.0; - - /** - * {@inheritDoc} - */ - @Override public Vector compute(Vector oldWeights, Vector oldGradient, Vector weights, Vector gradient, - int iteration) { - double learningRate = computeLearningRate(oldWeights != null ? oldWeights.copy() : null, - oldGradient != null ? oldGradient.copy() : null, weights.copy(), gradient.copy()); - - return weights.copy().minus(gradient.copy().times(learningRate)); - } - - /** */ - private double computeLearningRate(Vector oldWeights, Vector oldGradient, Vector weights, Vector gradient) { - if (oldWeights == null || oldGradient == null) - return INITIAL_LEARNING_RATE; - else { - Vector gradientDiff = gradient.minus(oldGradient); - - return weights.minus(oldWeights).dot(gradientDiff) / Math.pow(gradientDiff.kNorm(2.0), 2.0); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/optimization/SimpleUpdater.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/optimization/SimpleUpdater.java b/modules/ml/src/main/java/org/apache/ignite/ml/optimization/SimpleUpdater.java deleted file mode 100644 index 5079659..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/optimization/SimpleUpdater.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.optimization; - -import org.apache.ignite.ml.math.primitives.vector.Vector; - -/** - * Simple updater with fixed learning rate which doesn't guarantee convergence. - */ -public class SimpleUpdater implements Updater { - /** */ - private static final long serialVersionUID = 6417716224818162225L; - - /** */ - private final double learningRate; - - /** */ - public SimpleUpdater(double learningRate) { - assert learningRate > 0; - - this.learningRate = learningRate; - } - - /** - * {@inheritDoc} - */ - @Override public Vector compute(Vector oldWeights, Vector oldGradient, Vector weights, Vector gradient, - int iteration) { - return weights.minus(gradient.times(learningRate)); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/optimization/Updater.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/optimization/Updater.java b/modules/ml/src/main/java/org/apache/ignite/ml/optimization/Updater.java deleted file mode 100644 index 3d38119..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/optimization/Updater.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.optimization; - -import java.io.Serializable; -import org.apache.ignite.ml.math.primitives.vector.Vector; - -/** - * Weights updater applied on every gradient descent step to decide how weights should be changed. - */ -@FunctionalInterface -public interface Updater extends Serializable { - /** */ - public Vector compute(Vector oldWeights, Vector oldGradient, Vector weights, Vector gradient, int iteration); -} http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac2d4dd/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorDouble.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorDouble.java b/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorDouble.java deleted file mode 100644 index 1d0573d..0000000 --- a/modules/ml/src/main/java/org/apache/ignite/ml/structures/LabeledVectorDouble.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.ignite.ml.structures; - -import org.apache.ignite.ml.math.primitives.vector.Vector; - -/** - * Labeled vector specialized to double label. - * - * @param <V> Type of vector. - */ -public class LabeledVectorDouble<V extends Vector> extends LabeledVector<V, Double> { - /** - * Construct LabeledVectorDouble. - * - * @param vector Vector. - * @param lb Label. - */ - public LabeledVectorDouble(V vector, Double lb) { - super(vector, lb); - } - - /** - * Get label as double. - * - * @return label as double. - */ - public double doubleLabel() { - return label(); - } -}
