Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright [2013-2014] eBay Software Foundation Licensed 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 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 ml.shifu.guagua.mapreduce.example.nn;
Helper class for NN distributed training.
public final class NNUtils {
    private NNUtils() {

Generate basic NN network object
    public static BasicNetwork generateNetwork(int inint hiddenint out) {
        final BasicNetwork network = new BasicNetwork();
        network.addLayer(new BasicLayer(new ActivationLinear(), truein));
        network.addLayer(new BasicLayer(new ActivationSigmoid(), truehidden));
        network.addLayer(new BasicLayer(new ActivationSigmoid(), falseout));
        return network;

Determine the sign of the value.

value The value to check.
-1 if less than zero, 1 if greater, or 0 if zero.
    public static int sign(final double value) {
        if(Math.abs(value) < .) {
            return 0;
        } else if(value > 0) {
            return 1;
        } else {
            return -1;
    public static void randomize(int seeddouble[] weights) {
        NguyenWidrowRandomizer randomizer = new NguyenWidrowRandomizer(-1, 1);
New to GrepCode? Check out our FAQ X