package org.ea.javacnn.data;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Arrays;
import java.util.Random;
import java.io.Serializable;
/**
* Holding all the data handled by the network. So a layer will receive
* this class and return a similar block as a output that will be used
* by the next layer in the chain.
*
* @author Daniel Persson (mailto.woden@gmail.com)
*/
public class DataBlock implements Serializable {
private int sx;
private int sy;
private int depth;
private double[] w;
private double[] dw;
public DataBlock(int sx, int sy, int depth) {
this(sx, sy, depth, -1.0);
}
public DataBlock(int sx, int sy, int depth, double c) {
this.sx = sx;
this.sy = sy;
this.depth = depth;
int n = sx * sy * depth;
this.w = new double[n];
this.dw = new double[n];
if(c != -1.0) {
Arrays.fill(this.w, c);
} else {
double scale = Math.sqrt(1.0 / n);
Random r = new Random();
for(int i=0; i
Ads help maintain this website.