-
-
Save zoq/2143ce30da4b28e9c44751c0324b4aef to your computer and use it in GitHub Desktop.
template<typename ActionvationFunction = GaussianDistribution> | |
class MyFunction | |
{ | |
MyFunction(ActionvationFunction& actionvationFunction) : actionvationFunction(actionvationFunction) | |
{ | |
} | |
void Forward(...) | |
{ | |
// Provide every parameter that is needed for each activation function even if it's not needed for function A or function B. | |
actionvationFunction.Sample(...); | |
} | |
private: | |
ActionvationFunction actionvationFunction; | |
} | |
// Set all user defined parameter. | |
GaussianDistribution distribution(...); | |
MyFunction<GaussianDistribution> myfunction(distribution); |
I think i kinda figured it out. So basically what i wanted to do was
template< typename InputType = arma::vec, typename Distribution = GaussianDistribution, typename ... Args>
class GibbsSampler
{
public:
GibbsSampler(std::vector v, Distribution D, Args... args)
{
// Intialise the Distribution based on the args and v
// I think this is not possible this way( Or atleast i don't have to knowledge of how this could be done)
// We want to intialise a distribution which can have variable number of parameters. The parameters have to
// computed at run time using the input vector v
Distribution d(args(v))
}
Sample()
{
// Sample from the d
}
private:
// Some private variables
}
I think also Distribution right now defined in mlpack are not templated version they accept only arma::vec type as there input parameters we also would have to then make sure that args(functions) also return arma::vec.
I see what you mean. You could use variadic templates to achieve what you like but since the Args are user defined anyway, it would be easier to go with the solution I proposed above. Let the user pass an instantiated distribution. I don't think I see the benefit for letting GibbsSampler create the distribution instantiation for us.
GaussianDistribution distribution(Args);
MyFunction<GaussianDistribution> GibbsSampler(distribution);
Inside the class you can call e.g. the Sample function an pass the vector v Sample
distribution.Sample(v);
I am sorry but i can't understand. Can you give a more concrete example it would be really helpful.