Reduce subclass boilerplate by embracing duck-typing and adopting a...
Reduce subclass boilerplate by embracing duck-typing and adopting a "public-calls-private" design pattern. This pattern reduces lines of Distribution sub-class code by ~33%. Specifically, this change: 1. Makes BaseDistribution purely virtual. 2. The new idiom is that all public methods are implemented in the base class, and all possible argument checking is done there. Subclasses implement _methods called by the base class; if they fail to implement it will fire a NotImplementedError during tf graph construction. 3. Fix style inconsistencies, eg, function order, remove unnecessary indirection, use tf.ones instead of tf.constant, etc. 4. Fix efficiency when I noticed a problem. Example Dirichlet._variance. Change: 131404360
Loading
Please sign in to comment