Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Random;

public class Main {
    public static void initialize_weight(float[] weight, int size, boolean randomFlag) {
        // if randomFlag == true, generate weight randomly
        // otherwise, initialize all weight to 0.0
        Random randomGenerator = new Random();
        for (int i = 0; i < size; i++) {
            if (randomFlag == true) {
                weight[i] = randomGenerator.nextFloat();
            } else {
                weight[i] = (float) 0.0;
            }
        }
    }
}