Example #1
0
// class constructor
PoolLayer::PoolLayer(ivec inshape, ConvNet* net) :
    Fshape({2, 2}),
    InShape(inshape),
    Excitations(inshape[0], inshape[1], inshape[2])
{   
    Stride   = 2;
    
    OutShape = outshape(InShape, Fshape, Stride, 0);
    Steps    = calcsteps(InShape, Fshape, Stride, 0);
    
    Activations(OutShape[0], OutShape[1], OutShape[2]);
    Errors(OutShape[0], OutShape[1], OutShape[2]);
    Brain = net;
}
Example #2
0
ConvLayer::ConvLayer(int filters, ivec inshape, ivec fshape, int stride,
                     ConvNet* net)
{
    InShape  = inshape;
    Stride   = stride;
    Fshape   = fshape;
    OutShape = outshape(InShape, Fshape, Stride, filters);
    Steps    = calcsteps(InShape, Fshape, Stride, filters);
            
    dmatrix3 refE(OutShape[0], dmatrix2(OutShape[1], dvec(OutShape[2], 0.0)));
    refE.swap(Excitations);
    dmatrix3 refA(OutShape[0], dmatrix2(OutShape[1], dvec(OutShape[2], 0.0)));
    refA.swap(Activations);
    dmatrix3 refErr(OutShape[0],dmatrix2(OutShape[1],dvec(OutShape[2], 0.0)));
    refErr.swap(Errors);
    dmatrix4 flt(filters,dmatrix3(InShape[0],
                 dmatrix2(Fshape[0],dvec(Fshape[1], 0.5))));
    flt.swap(Filters);
    
    Brain = net;
}