示例#1
0
/* Computes p*Delta.							*
 * This will only be run once!						*/
struct polynomial compute_delta(void)
{
	int i;
	struct polynomial A, B, C;
	A.leading = NULL;
	B.leading = NULL;
	C.leading = NULL;

	A = copy_pol(myf);
	B = copy_pol(myf);
	for (i = 2; i <= p; i++)
	{
		C = pol_mult(A, B);
		free_tail(B.leading);
		B = C;
		C.leading = NULL;
		C.degree = 0;
	}
	free_tail(A.leading);
	A.leading = NULL;
	A.degree = 0;
	A = frobenius(myf);

	/* Replace A by negative. */
	times_int(-1, &A);

	/* Add -F(f) + f^p */
	C = pol_add(A, B);

	free_tail(A.leading);
	free_tail(B.leading);
	
	return(C);
}
示例#2
0
dmatrix3 ConvLayer::think(dmatrix3 mat)
{
    dmatrix3 slab(mat.size(), dmatrix2(Fshape[1], dvec(Fshape[0])));
    ivec step(4);
    dvec exc(OutShape[1]*OutShape[2]);
    dvec act(OutShape[1]*OutShape[2]);
       
    ivec foldshape(2);
    foldshape[0] = OutShape[1];
    foldshape[1] = OutShape[2];
    
    Inputs = &mat;
    
    for(int f=0;f<Filters.size();f++) {
        dmatrix3 filt = Filters[f];
        for(int i=0;i<Steps.size();i++) {
            step = Steps[i];
            slab = invert<real>(slice<real>(invert<real>(mat), step));
            exc[i] = frobenius(slab, filt); // This is the "convolve" step
            act[i] = sigmoid(exc[exc.size()-1]);
        }
        Excitations[f] = fold2<real>(exc, foldshape);
        Activations[f] = fold2<real>(act, foldshape);
    }
    return Activations;
}
示例#3
0
unsigned long zz_pEExtraInfoT::frobenius(unsigned long x)
{
    if (frob_map != NULL)
        return frob_map->map[x];

    zz_pE  _x, _y;

    from_ulong(x, _x);
    frobenius(_x, _y);
    return to_ulong(_y);
}
示例#4
0
void ConvLayer::weight_update(dmatrix3* inputs)
{
    assert(Errors.size()==Filters.size());
    
    std::size_t sh[4] = {Filters.size(),Filters[0].size(),
                 Filters[0][0].size(),Filters[0][0][0].size()};
    ivec step(4);
    dmatrix2 sheet;
    
    for(int f=0;f<sh[0];f++) {
        for(int z=0;z<sh[1];z++) {
            for(int y=0;y<sh[2];y++) {
                for(int x=0;x<sh[3];x++) {
                    step[0] = x; step[1] = x + OutShape[2];
                    step[2] = y; step[3] = y + OutShape[1];
                    
                    sheet = slice<real>(inputs->at(z), step);
                    
                    Filters[f][z][y][x] += frobenius(Errors[f], sheet);
                }
            }
        }
    }
}