--- Log opened Tue Jul 03 00:00:52 2018 | ||
-!- witness_ [uid10044@gateway/web/irccloud.com/x-fdfpugnyekzyzdmv] has joined #shogun | 11:29 | |
@HeikoS | lisitsyn: hi | 11:31 |
---|---|---|
@HeikoS | lisitsyn: I was more asking about some other design question we have | 11:32 |
@HeikoS | lisitsyn: but yeah the lazy would be good as well | 11:32 |
@HeikoS | lisitsyn: as for lazy thoughts | 11:55 |
@HeikoS | I need some mechanism to "filter out" these lazy any instances in clone/equals. Once that is possible (or maybe it is already), we can merge and use this. thanks for taking care | 11:55 |
lisitsyn | oops | 12:12 |
lisitsyn | HeikoS: could you please highlight me all the times so if I get distracted you don't stay unanswered :) | 12:12 |
@HeikoS | lisitsyn: sure :) | 12:13 |
lisitsyn | so what's the q? | 12:13 |
@HeikoS | lisitsyn: multiple | 12:14 |
@HeikoS | lisitsyn: first for the lazy | 12:14 |
@HeikoS | can I filter out the lazy anys? | 12:15 |
@HeikoS | lisitsyn: for clone/equals? | 12:15 |
lisitsyn | yeah we can add just another flag | 12:15 |
lisitsyn | easy | 12:15 |
@HeikoS | lisitsyn: ok cool, because once that is there, we can merge it | 12:15 |
lisitsyn | lets just avoid clutter though | 12:15 |
@HeikoS | lisitsyn: agree | 12:15 |
lisitsyn | yeah and I have to check the test | 12:15 |
@HeikoS | lisitsyn: ok the other q is about dispatching | 12:15 |
lisitsyn | surprising it crashed something else | 12:15 |
lisitsyn | ok | 12:15 |
@HeikoS | have you seen the LARS pr? | 12:15 |
lisitsyn | not yet let me glance | 12:16 |
@HeikoS | lisitsyn: https://github.com/shogun-toolbox/shogun/pull/4350 | 12:16 |
@HeikoS | goal: we want to make the train methods templated, so we know the feature type inside, and algorithm authors dont need to dispatch the type | 12:16 |
@HeikoS | problem: templated methods cannot be virtual | 12:16 |
lisitsyn | ah yeah | 12:16 |
@HeikoS | one idea (in the PR): have a macro generate dispatching code | 12:17 |
lisitsyn | I actually checked the mail but I didn't have much to say | 12:17 |
lisitsyn | but do we have that many instances of that tempate? | 12:17 |
@HeikoS | float16/32/64 | 12:17 |
@HeikoS | more for string features | 12:17 |
lisitsyn | aha I see | 12:18 |
@HeikoS | thats option A, do the dispatching in the subclass | 12:18 |
lisitsyn | another question I'd sk | 12:18 |
@HeikoS | option b would be different | 12:18 |
lisitsyn | do we really need to see the types in the code? | 12:18 |
@HeikoS | lisitsyn: well | 12:18 |
@HeikoS | good q | 12:18 |
@HeikoS | linalg is typed | 12:18 |
lisitsyn | can we coffin-like do something without knowing the type? | 12:18 |
@HeikoS | we can make it untyped | 12:18 |
@HeikoS | but then the same problem is just pushed further down | 12:18 |
@HeikoS | at some point you need the type | 12:19 |
@HeikoS | and I fear that the lower it is, the more often we need to dispatch | 12:19 |
@HeikoS | imagine it was in linalg | 12:19 |
@HeikoS | need to dispatch in every single call | 12:19 |
lisitsyn | yes that's true | 12:19 |
@HeikoS | also shoguns algorithms are written against fixed types most of the time, not everywhere though | 12:19 |
@HeikoS | so option B is the other extreme: make everything typed | 12:19 |
@HeikoS | i.e. make all algorithms a template that has the feature type | 12:20 |
lisitsyn | but how does that work? | 12:20 |
@HeikoS | then we can have virtual train_machine methods | 12:20 |
lisitsyn | do we write templated code in CLARS? | 12:20 |
@HeikoS | yes | 12:20 |
@HeikoS | check it | 12:20 |
lisitsyn | aha I see | 12:20 |
@HeikoS | train_machine dispatches | 12:20 |
lisitsyn | yeah I am checking | 12:20 |
@HeikoS | and then calls train_machine_templated | 12:20 |
@HeikoS | lisitsyn: so moving the template into the class def would just make everything typed at compile time | 12:21 |
lisitsyn | ok so the problem is basically in a untyped bottleneck that should call the templated code | 12:21 |
@HeikoS | yes | 12:21 |
@HeikoS | and this could be avoided via moving it all up in the hierarchy | 12:21 |
@HeikoS | the extreme case is making CMachine templated | 12:21 |
@HeikoS | lisitsyn: this has a few more implications of course | 12:22 |
lisitsyn | sounds like static polymorphismish thingy | 12:22 |
@HeikoS | yes exactly | 12:22 |
lisitsyn | CRTP is used sometimes | 12:22 |
@HeikoS | yes exactly | 12:22 |
@HeikoS | but think about the user | 12:22 |
@HeikoS | from C++ this means that you need to know what feature type you have at instantiation of the machine | 12:22 |
@HeikoS | which is OK, since we are c++ | 12:22 |
@HeikoS | for swig, one could have a special wrapper | 12:22 |
@HeikoS | that would accept CFeatures* | 12:23 |
@HeikoS | and then does all the dispatching to the C++ calls | 12:23 |
lisitsyn | yeah but why not to add some intermediate CRTP CTypedMachine? | 12:23 |
@HeikoS | but then doing this requires a lot of changes to shogun, as we dont use static polymorphism | 12:23 |
@HeikoS | or that | 12:23 |
@HeikoS | point is everything is typed | 12:23 |
lisitsyn | I mean CTypedMachine does dispatching into templated methods of type T | 12:24 |
@HeikoS | and then there is a special dispatcher machine | 12:24 |
@HeikoS | yeah | 12:24 |
@HeikoS | but then there are things like | 12:24 |
@HeikoS | xvalidation | 12:24 |
lisitsyn | you can even 'dispatch or die' | 12:24 |
@HeikoS | which uses the CMachine and CFeatures interface | 12:24 |
@HeikoS | i.e. thats not static polymorphism | 12:24 |
@HeikoS | so there is some refactoring required | 12:24 |
@HeikoS | unless we add this class you meant | 12:25 |
@HeikoS | ah another thing | 12:25 |
@HeikoS | from swig | 12:25 |
@HeikoS | we still want | 12:25 |
@HeikoS | svm = machine("LibSVM") | 12:25 |
lisitsyn | but this does not matter much I think | 12:25 |
@HeikoS | but we cannot instantiate the C++ machine yet, as we dont know the type | 12:25 |
@HeikoS | so that only would happen when calling | 12:25 |
@HeikoS | svm.train(features) | 12:25 |
lisitsyn | hmm let's use some shared notebook so I can outline some code for you | 12:26 |
lisitsyn | docs? | 12:26 |
@HeikoS | I guess in summary, option B means: clearly separate a typed interface from an untyped one | 12:26 |
@HeikoS | yeah sure | 12:26 |
@HeikoS | it is not like I dont know how to do these things | 12:26 |
@HeikoS | it is I am asking what we should do | 12:26 |
@HeikoS | the macro in the PR is a minimal solution that kind of sidesteps the problem | 12:26 |
lisitsyn | https://docs.google.com/document/d/1qNsj2sTvM5R8GUTaj306olimPQyERnXRX1TkVOX6KSg/edit?usp=sharing | 12:27 |
@HeikoS | lisitsyn: but I am now thinking that there maybe should be a fully typed interface | 12:27 |
@HeikoS | where all data types are template parameters | 12:27 |
@HeikoS | Ill be back in a sec | 12:27 |
lisitsyn | HeikoS: ok is that a solution? | 12:30 |
@HeikoS | lisitsyn: back | 12:31 |
@HeikoS | checking | 12:31 |
@HeikoS | lisitsyn: i think this doesnt work | 12:33 |
@HeikoS | lisitsyn: I had this idea as well | 12:33 |
lisitsyn | why? | 12:33 |
@HeikoS | but we got a compiler error | 12:33 |
lisitsyn | I think that's resolvable | 12:33 |
@HeikoS | because inside CTypedMachine, ::train is not visible or? | 12:33 |
lisitsyn | it is because TypedMachine is templated against T | 12:34 |
@HeikoS | it is a mixin type of dispatcher | 12:34 |
@HeikoS | let me dig out my old gist so we can compare | 12:34 |
lisitsyn | HeikoS: it might be that templated train should become static | 12:34 |
@HeikoS | https://gist.github.com/karlnapf/95a9c72a642d61ec268a39407f8761b2 | 12:34 |
lisitsyn | but that's also fine, you can pass this into it | 12:34 |
lisitsyn | HeikoS: I think some SFINAE detecting the function and then fall-backing into SG_NOTIMPLEMENTED might resolve all the things | 12:35 |
lisitsyn | HeikoS: you might need to make it static | 12:36 |
@HeikoS | https://gist.github.com/karlnapf/95a9c72a642d61ec268a39407f8761b2#file-dispatch_features-cpp-L38 | 12:36 |
@HeikoS | this line didnt compile | 12:36 |
lisitsyn | T::train_machine_dense<float64_t>(this, f->as<CDenseFeatures<float64_t>()) | 12:36 |
@HeikoS | y | 12:36 |
lisitsyn | this should work | 12:36 |
@HeikoS | ah man | 12:36 |
@HeikoS | easy :D | 12:36 |
@HeikoS | ok | 12:37 |
@HeikoS | Ill ask shubham to try that | 12:37 |
@HeikoS | I like this solution | 12:37 |
lisitsyn | it should work from my point of view but lets see | 12:37 |
lisitsyn | it needs some trickery with method_or_fallback | 12:37 |
lisitsyn | otherwise all the subclasses would have to implement all the stuff | 12:37 |
@HeikoS | yeah sure | 12:38 |
@HeikoS | I was hoping for a compiler error | 12:38 |
@HeikoS | if the downstream class doenst implement | 12:38 |
@HeikoS | train_dense | 12:38 |
@HeikoS | and then we need one of those dispatchers for every feature class | 12:38 |
lisitsyn | this might slowdown things at compilation time quite a bit | 12:40 |
lisitsyn | :D | 12:40 |
lisitsyn | oh lets see | 12:40 |
@HeikoS | yeah | 12:40 |
@HeikoS | lisitsyn: ok so we have 3 options then | 12:40 |
@HeikoS | a the macro | 12:40 |
@HeikoS | b the mixin | 12:40 |
@HeikoS | c making everything static and dispatch in wrapper classes | 12:40 |
lisitsyn | yeah it seems so | 12:40 |
@HeikoS | Class CLARS : public CTypedMachine<CLARS> | 12:42 |
@HeikoS | this klind of stuff | 12:42 |
@HeikoS | lisitsyn: you sure about this line | 12:43 |
lisitsyn | yes, why not? | 12:43 |
@HeikoS | classic CRTP | 12:44 |
@HeikoS | mind boggling | 12:44 |
lisitsyn | it might be mixin like in your example | 12:44 |
lisitsyn | ah | 12:44 |
lisitsyn | it is kind of useful sometimes | 12:44 |
@HeikoS | in my example it is the other way artound | 12:44 |
@HeikoS | as the mixing inherits from CLinearMachine | 12:44 |
@HeikoS | thats the key difference | 12:44 |
@HeikoS | and CLinearMachine::train is not defined | 12:45 |
@HeikoS | thats why we had the error | 12:45 |
@HeikoS | but in your case | 12:45 |
@HeikoS | CTypedMachine inherits from CLARS | 12:45 |
@HeikoS | so the T::train is defined (if the user doies that) | 12:45 |
@HeikoS | not user, developer | 12:45 |
@HeikoS | lisitsyn: ok thanks! | 12:47 |
@HeikoS | really useful! | 12:47 |
lisitsyn | glad to help :P | 12:47 |
@HeikoS | lisitsyn: whats your thoughts on multiple inheritance in that example | 13:07 |
@HeikoS | i.e. CLinearMachine | 13:07 |
@HeikoS | lisitsyn: thought on that? | 15:28 |
@HeikoS | wiking: will you host the zoom? | 16:00 |
@HeikoS | otherwise we can use hangouts | 16:00 |
@HeikoS | pls ping me if youi want to join | 16:01 |
wuwei | heiko: i'm here | 16:04 |
-!- witness_ [uid10044@gateway/web/irccloud.com/x-fdfpugnyekzyzdmv] has quit [Quit: Connection closed for inactivity] | 17:05 | |
-!- travis-ci [~travis-ci@ec2-54-161-216-78.compute-1.amazonaws.com] has joined #shogun | 17:08 | |
travis-ci | it's Wuwei Lin's turn to pay the next round of drinks for the massacre he caused in shogun-toolbox/shogun: https://travis-ci.org/shogun-toolbox/shogun/builds/399604213 | 17:08 |
-!- travis-ci [~travis-ci@ec2-54-161-216-78.compute-1.amazonaws.com] has left #shogun [] | 17:08 | |
@HeikoS | lisitsyn: static typing might also be a way towards making Some possible as not more incompatible types between Some<CFeatures> and Some<CDenseFeatures> | 17:19 |
-!- HeikoS [~heiko@2a00:23c5:e10a:5c00:5d03:1daf:b851:6a31] has quit [Quit: Leaving.] | 18:55 | |
-!- travis-ci [~travis-ci@ec2-54-234-101-19.compute-1.amazonaws.com] has joined #shogun | 19:08 | |
travis-ci | it's Shubham Shukla's turn to pay the next round of drinks for the massacre he caused in shubham808/shogun: https://travis-ci.org/shubham808/shogun/builds/399664412 | 19:08 |
-!- travis-ci [~travis-ci@ec2-54-234-101-19.compute-1.amazonaws.com] has left #shogun [] | 19:08 | |
-!- travis-ci [~travis-ci@ec2-54-161-216-78.compute-1.amazonaws.com] has joined #shogun | 19:36 | |
travis-ci | it's Shubham Shukla's turn to pay the next round of drinks for the massacre he caused in shubham808/shogun: https://travis-ci.org/shubham808/shogun/builds/399654411 | 19:36 |
-!- travis-ci [~travis-ci@ec2-54-161-216-78.compute-1.amazonaws.com] has left #shogun [] | 19:36 | |
-!- travis-ci [~travis-ci@ec2-54-234-101-19.compute-1.amazonaws.com] has joined #shogun | 19:45 | |
travis-ci | it's Shubham Shukla's turn to pay the next round of drinks for the massacre he caused in shubham808/shogun: https://travis-ci.org/shubham808/shogun/builds/399675202 | 19:45 |
-!- travis-ci [~travis-ci@ec2-54-234-101-19.compute-1.amazonaws.com] has left #shogun [] | 19:45 | |
--- Log closed Wed Jul 04 00:00:53 2018 |
Generated by irclog2html.py 2.10.0 by Marius Gedminas - find it at mg.pov.lt!