package org.ea.javacnn.layers;
import org.ea.javacnn.data.BackPropResult;
import org.ea.javacnn.data.DataBlock;
import org.ea.javacnn.data.OutputDefinition;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* This layer uses different filters to find attributes of the data that
* affects the result. As an example there could be a filter to find
* horizontal edges in an image.
*
* @author Daniel Persson (mailto.woden@gmail.com)
*/
public class ConvolutionLayer implements Layer,Serializable {
private double l1_decay_mul = 0.0;
private double l2_decay_mul = 1.0;
private DataBlock in_act;
private DataBlock out_act;
private final float BIAS_PREF = 0.1f;
private int out_depth, out_sx, out_sy;
private int in_depth, in_sx, in_sy;
private int sx, sy;
private int stride, padding;
private List filters;
private DataBlock biases;
public ConvolutionLayer(OutputDefinition def, int sx, int filters, int stride, int padding) {
// required
this.out_depth = filters;
this.sx = sx; // filter size. Should be odd if possible, it's cleaner.
this.in_depth = def.getDepth();
this.in_sx = def.getOutX();
this.in_sy = def.getOutY();
// optional
this.sy = this.sx;
this.stride = stride;
this.padding = padding;
// computed
// note we are doing floor, so if the strided convolution of the filter doesnt fit into the input
// volume exactly, the output volume will be trimmed and not contain the (incomplete) computed
// final application.
this.out_sx = (int)Math.floor((this.in_sx + this.padding * 2 - this.sx) / this.stride + 1);
this.out_sy = (int)Math.floor((this.in_sy + this.padding * 2 - this.sy) / this.stride + 1);
// initializations
this.filters = new ArrayList();
for(int i=0;i=0 && oy=0 && ox=0 && oy=0 && ox getBackPropagationResult() {
List results = new ArrayList();
for(int i=0;i
Ads help maintain this website.