Open CTinRay opened 7 years ago
You may want to implement function
void ConstructGraph(FactorGraph& graph);
Update class defs. I will push it to github latter.
class GFactorFunction: FactorFunction{
public:
Real beta;
GFactorFunction(Real beta);
Real eval(const std::vector<Label>&args) const{
return expl(beta * args[0] * args[1]);
}
};
class FFactorFunction: FactorFunction{
static std::vector<Real>alpha;
std::vector<Real>&features;
FFactorFunction(const std::vector<Real>&features);
Real eval(const std::vector<Label>&args) const{
return expl(args[0] * (alpha[0] * features[0] +
alpha[1] * features[1] +
alpha[2] * features[2] ) );
}
};
class HFactorFunction: FactorFunction{
static Real gamma;
unsigned int ti;
std::vector<Real>&features;
HFactorFunction(unsigned int ti);
Real eval(const std::vector<Label>&args) const{
unsigned int count = 0;
for (unsigned int i = 0; i < args.size(); ++i ){
count += args[i] == 1 ? 1 : 0;
}
return expl(gamma * (ti - count) * (ti - count));
}
};
If you have done, tell me how to use your function(s) to construct graph here.
And make pull request as well, I will merge you into master.
You have two function class (for h(y), not defined yet)
And one function to add factor