10 this->growth_rate = .001;
11 this->shrink_rate = 0.0;
12 this->plugin_name =
"SimpleMax";
15 SimpleMax::~SimpleMax()
19 void SimpleMax::init(
int num_classes)
21 this->num_classes = num_classes;
26 std::map<std::string, CEBL::Param> SimpleMax::getParamsList()
28 std::map<std::string, CEBL::Param> params;
31 "How much to grow classes on each update based on their probability.",
39 "How much to shrink all classes on each update.",
50 void SimpleMax::setParamsList( std::map<std::string, CEBL::Param> &p)
52 this->growth_rate = p[
"g"].getDouble();
53 this->shrink_rate = p[
"s"].getDouble();
57 void SimpleMax::updateWithProbabilities(std::vector<double> probs)
59 if(probs.size() != unsigned(num_classes))
61 this->init(probs.size());
65 this->proportions.resize(num_classes);
66 for(
int i=0;i<num_classes;i++)
68 double growth = (growth_rate + shrink_rate) * probs[i]
70 this->proportions[i] += growth;
71 if(this->proportions[i] < 0)
72 this->proportions[i] = 0;
78 std::vector<double> SimpleMax::decideClasses()
80 std::vector<double> ret = this->proportions;
81 ublas::vector<double> props =
asUblasVector(this->proportions);
85 props =
rep(0.0, num_classes);
100 map<string, SerializedObject> ret;
101 ret[
"growth_rate"] =
serialize(growth_rate);
102 ret[
"shrink_rate"] =
serialize(shrink_rate);