private void forward_convolute_on_depth(UnitLayer to, int stride, int depth, int length) { int to_depth = depth + length; if (to_depth >= to.Depth) { to_depth = to.Depth; } for (int d = depth; d < to_depth; d++) { WeightLayer weights = WeightLayerPool.find(Id, to.Id, d); int width_of_weights = weights.Width, height_of_weights = weights.Height; int width_of_units = to.Width, height_of_units = to.Height; for (int y = 0; y < height_of_units; y++) { int top = y * stride; int bottom = top + height_of_weights; for (int x = 0; x < width_of_units; x++) { int left = x * stride; to.set_value_at_inport(x, y, d, weights.convolute_product(left, top, left + width_of_weights, bottom, Units)); } } } }
public void forward_average_pool(UnitLayer to, int width, int height, int stride) { int width_of_units = to.Width, height_of_units = to.Height; for (int d = 0; d < Depth; d++) { for (int y = 0; y < height_of_units; y++) { int top = y * stride; int bottom = top + height; for (int x = 0; x < width_of_units; x++) { int left = x * stride; to.set_value_at_inport(x, y, d, average_pool(left, top, left + width, bottom, d)); } } } }
private void forward_fully_connect_on_depth(UnitLayer to, int depth, int length) { int width = to.Width, height = to.Height; int to_depth = depth + length; if (to_depth >= to.Depth) { to_depth = to.Depth; } for (int d = depth; d < to_depth; d++) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { WeightLayer weights = WeightLayerPool.find(Id, to.Id, x, y, d); to.set_value_at_inport(x, y, d, weights.fully_product(Units)); } } } }