curt_3d3_frac,// final double curt_3d3_frac, // = 0.5; // for stronger signals give this fraction of the total (of 9) weight to the 1-of-9 winner
curt_3d3_thrsh,//final double curt_3d3_thrsh, // = 1.0; // scale down curt_3d3_frac for weaker signals (in ratio of min(data[now]/curt_3d3_thrsh,1.0)
curt_3d3_power,//final double curt_3d3_power, // = 2.0; // in mode_3d3=2, redistribute coarse velocities weights as the specified power of their positive values (ignore negative ones)
w3d3_now,// final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
w3d3_now,// final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
w3d3_prev,// final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
w3d3_prev,// final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
curt_3d3_frac,// final double curt_3d3_frac, // = 0.5; // for stronger signals give this fraction of the total (of 9) weight to the 1-of-9 winner
curt_3d3_thrsh,//final double curt_3d3_thrsh, // = 1.0; // scale down curt_3d3_frac for weaker signals (in ratio of min(data[now]/curt_3d3_thrsh,1.0)
curt_3d3_power,//final double curt_3d3_power, // = 2.0; // in mode_3d3=2, redistribute coarse velocities weights as the specified power of their positive values (ignore negative ones)
w3d3_now,// final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
w3d3_now,// final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
w3d3_prev,// final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
w3d3_prev,// final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
thrownewIllegalArgumentException("Kernel length = "+kernel.length+" does not match kernel size (2*"+kernel2d_rad+"+1) * (2*"+kernel2d_rad+"+1) ="+(kernel_size*kernel_size));
thrownewIllegalArgumentException("Kernel length = "+kernel.length+" does not match kernel size (2*"+kernel2d_rad+"+1) * (2*"+kernel2d_rad+"+1) ="+(kernel_size*kernel_size));
}
}
}
}
publicdouble[][][]convolve3d(
publicdouble[][][]convolve3d(
finaldouble[][][]data,// outer index - historic layers, [0] - latest, second index - pixel, third - direction ([9])
finaldouble[][][]data,// outer index - historic layers, [0] - latest, second index - pixel, third - direction ([9])
double[][][]result_in){
double[][][]result_in){
...
@@ -198,8 +199,6 @@ public class CuasRTUtils {
...
@@ -198,8 +199,6 @@ public class CuasRTUtils {
for(intnhist=0;nhist<nlayers;nhist++){
for(intnhist=0;nhist<nlayers;nhist++){
finalintfhist=nhist;
finalintfhist=nhist;
finalintspat_rad=consolidationKernel.getSpatialRadius();// may be later dependent on nhist for efficiency
finalintspat_rad=consolidationKernel.getSpatialRadius();// may be later dependent on nhist for efficiency
// final int spat_dim = consolidationKernel.getSpatialDim();
// final int tl_offset = spat_rad * (width+1);
finaldouble[][][][]kernel_hist=kernel[fhist];
finaldouble[][][][]kernel_hist=kernel[fhist];
finaldouble[][]data_hist=data[fhist];
finaldouble[][]data_hist=data[fhist];
ai.set(0);
ai.set(0);
...
@@ -289,6 +288,330 @@ public class CuasRTUtils {
...
@@ -289,6 +288,330 @@ public class CuasRTUtils {
}
}
returnresult;
returnresult;
}
}
publicdouble[][]convolve3D3LReLU(
finaldouble[]data,
finaldouble[]data_prev,
double[][]result_in,
finalintmode_3d3,
finaldoublecurt_3d3_frac,// = 0.5; // for stronger signals give this fraction of the total (of 9) weight to the 1-of-9 winner
finaldoublecurt_3d3_thrsh,// = 1.0; // scale down curt_3d3_frac for weaker signals (in ratio of min(data[now]/curt_3d3_thrsh,1.0)
finaldoublecurt_3d3_power,// = 2.0; // in mode_3d3=2, redistribute coarse velocities weights as the specified power of their positive values (ignore negative ones)
finaldoublew_now,// normally 0.5, so center will propagate to the next pyramid levels
finaldoublew_prev,// normally 0.5, so center will propagate to the next pyramid levels
finaldoublealpha,
finalintdebugLevel){
switch(mode_3d3){
caseCuasDetectRT.CONV3D3_MODE_PLAIN:
returnconvolve3D3LReLU(
data,// final double [] data,
data_prev,// final double [] data_prev,
result_in,// double [][] result_in,
w_now,// final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
w_prev,// final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
alpha,// final double alpha,
debugLevel);// final int debugLevel)
caseCuasDetectRT.CONV3D3_MODE_WINNER:
returnconvolve3D3LReLU(
data,// final double [] data,
data_prev,// final double [] data_prev,
result_in,// double [][] result_in,
curt_3d3_frac,// final double curt_3d3_frac, // = 0.5; // for stronger signals give this fraction of the total (of 9) weight to the 1-of-9 winner
curt_3d3_thrsh,//final double curt_3d3_thrsh, // = 1.0; // scale down curt_3d3_frac for weaker signals (in ratio of min(data[now]/curt_3d3_thrsh,1.0)
w_now,// final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
w_prev,// final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
alpha,// final double alpha,
debugLevel);// final int debugLevel)
caseCuasDetectRT.CONV3D3_MODE_POWER:
returnconvolve3D3LReLU(
data,// final double [] data,
data_prev,// final double [] data_prev,
result_in,// double [][] result_in,
curt_3d3_frac,// final double curt_3d3_frac, // = 0.5; // for stronger signals give this fraction of the total (of 9) weight to the 1-of-9 winner
curt_3d3_thrsh,// final double curt_3d3_thrsh, // = 1.0; // scale down curt_3d3_frac for weaker signals (in ratio of min(data[now]/curt_3d3_thrsh,1.0)
curt_3d3_power,// final double curt_3d3_power, // = 2.0; // in mode_3d3=2, redistribute coarse velocities weights as the specified power of their positive values (ignore negative ones)
w_now,// final double w_now, // normally 0.5, so center will propagate to the next pyramid levels
w_prev,// final double w_prev,// normally 0.5, so center will propagate to the next pyramid levels
alpha,// final double alpha,
debugLevel);// final int debugLevel)
default:
System.out.println("convolve3D3LReLU(): mode_3d3="+mode_3d3+" is undefined");
returnnull;
}
}
/**
*
* @param data
* @param data_prev
* @param result_in
* @param curt_3d3_frac
* @param curt_3d3_thrsh
* @param w_now
* @param w_prev
* @param alpha
* @param debugLevel
* @return
*/
publicdouble[][]convolve3D3LReLU(
finaldouble[]data,
finaldouble[]data_prev,
double[][]result_in,
finaldoublecurt_3d3_frac,// = 0.5; // for stronger signals give this fraction of the total (of 9) weight to the 1-of-9 winner
finaldoublecurt_3d3_thrsh,// = 1.0; // scale down curt_3d3_frac for weaker signals (in ratio of min(data[now]/curt_3d3_thrsh,1.0)
finaldoublew_now,// normally 0.5, so center will propagate to the next pyramid levels
finaldoublew_prev,// normally 0.5, so center will propagate to the next pyramid levels
finaldoublecurt_3d3_frac,// = 0.5; // for stronger signals give this fraction of the total (of 9) weight to the 1-of-9 winner
finaldoublecurt_3d3_thrsh,// = 1.0; // scale down curt_3d3_frac for weaker signals (in ratio of min(data[now]/curt_3d3_thrsh,1.0)
finaldoublecurt_3d3_power,// = 2.0; // in mode_3d3=2, redistribute coarse velocities weights as the specified power of their positive values (ignore negative ones)
finaldoublew_now,// normally 0.5, so center will propagate to the next pyramid levels
finaldoublew_prev,// normally 0.5, so center will propagate to the next pyramid levels
// === Coarse velocities layer (from -1 to +1 in each direction, 9 total) ===
publicintcurt_3d3_mode=2;// 0 (plain) integration, 1 - fraction to the winner, 2 use strength power
publicdoublecurt_3d3_frac=0.5;// for stronger signals give this fraction of the total (of 9) weight to the 1-of-9 winner
publicdoublecurt_3d3_thrsh=1.0;// scale down curt_3d3_frac for weaker signals (in ratio of min(data[now]/curt_3d3_thrsh,1.0)
publicdoublecurt_3d3_power=2.0;// in mode_3d3=2, redistribute coarse velocities weights as the specified power of their positive values (ignore negative ones)
publicdoublecurt_3d3_wnow=0.5;// Weight of the latest (now) temporal slice when creating coarse velocities
publicdoublecurt_3d3_wnow=0.5;// Weight of the latest (now) temporal slice when creating coarse velocities
publicdoublecurt_3d3_wprev=0.5;// Weight of the previous temporal slice when creating coarse velocities
publicdoublecurt_3d3_wprev=0.5;// Weight of the previous temporal slice when creating coarse velocities
publicdoublecurt_rleak1=0.1;// 1-ReLU leak (0 - linear, 1.0 - classic ReLU) for the coarse velocity 3d convolution
publicdoublecurt_rleak1=0.1;// 1-ReLU leak (0 - linear, 1.0 - classic ReLU) for the coarse velocity 3d convolution