Exemplo n.º 1
0
////////////////////////////////////////////////////////////////////////////////////////////////////
///// skill.h
void SkillLevel::serialize(JsonOut &json) const
{
    json.start_object();
    json.member("level", level() );
    json.member("exercise", exercise(true) );
    json.member("istraining", isTraining() );
    json.member("lastpracticed", int ( lastPracticed() ) );
    json.end_object();
}
Exemplo n.º 2
0
void DestinNetworkAlt::init(SupportedImageWidths width, unsigned int layers,
                            unsigned int centroid_counts [], bool isUniform,
                            int extRatio, unsigned int layer_widths[]){
    callback = NULL;
    initTemperatures(layers, centroid_counts);

    DestinConfig *dc = CreateDefaultConfig(layers);
    dc->addCoeff = 0; // disabled addition of centroids
    dc->beta = 0.01;
    std::copy(centroid_counts, centroid_counts + layers, dc->centroids); // initial number of centroids
    dc->extRatio = extRatio;
    dc->freqCoeff = 0.05;
    dc->freqTreshold = 0; // disabled deletion of centroids
    dc->gamma = gamma;
    dc->isUniform = isUniform;
    dc->lambdaCoeff = lambdaCoeff;
   
    std::copy(centroid_counts, centroid_counts + layers, dc->layerMaxNb); // max number of centroids

    if(layer_widths != NULL){ // provide support for non standard heirarchy
        std::copy(layer_widths, layer_widths + layers, dc->layerWidths);
    }

    if(width % dc->layerWidths[0] == 0){
        int ratio = width / dc->layerWidths[0];
        dc->inputDim = ratio * ratio;
    } else {
        DestroyConfig(dc);
        throw std::runtime_error("Input image width must be evenly divisible by the bottom layer width.");
    }

    dc->nClasses = 0;
    dc->nMovements = 0; //this class does not use movements
    dc->starvCoeff = 0.05;
    std::copy(temperatures, temperatures + layers, dc->temperatures);

    destin = InitDestinWithConfig(dc);
    destin->rindex=0;
    if(destin == NULL){
        throw std::runtime_error("Could not create the destin structure. Perhaps the given layer widths is not supported.");
    }

    DestroyConfig(dc);

    setBeliefTransform(DST_BT_NONE);
    ClearBeliefs(destin);
    SetLearningStrat(destin, CLS_FIXED);
    destin->fixedLearnRate = 0.1;
    isTraining(true);
}