Cleanup and optimize transformers - #4348
Conversation
vinx13
commented
Jun 28, 2018
- Use linalg in NormOne
- Optimize PruneVarSubMean
550639e to
af8af72
Compare
|
This needs a rebase |
|
Btw whenever you make something linalg, pls ensure there is some test coverage of the changes lines, so that we at least know he results didn’t change in the integration test examples |
dedcb4a to
bdacb07
Compare
| EXPECT_EQ(v.vlen, num_features); | ||
| for (auto j : range(v.vlen)) | ||
| { | ||
| EXPECT_DOUBLE_EQ(v[j], data[num_features * i + j] / norm[i]); |
| { | ||
| SGVector<float64_t> v = feats->get_feature_vector(i); | ||
| auto result = transformer->apply_to_feature_vector(v); | ||
| EXPECT_EQ(result.vlen, num_features); |
| CPruneVarSubMean::apply_to_matrix(SGMatrix<float64_t> matrix) | ||
| { | ||
| ASSERT(m_initialized) | ||
| REQUIRE(m_initialized, "Transformer has not been fitted.\n"); |
There was a problem hiding this comment.
offtopic: I would love to move all those general checks to base classes so that they dont get repeated in every specialization....
any thoughts on this
There was a problem hiding this comment.
shouldn't we use a different exception type other than ShogunException
77a9f85 to
8711ea6
Compare
c1b0299 to
47363cb
Compare
47363cb to
918fead
Compare
| CPruneVarSubMean::apply_to_matrix(SGMatrix<float64_t> matrix) | ||
| { | ||
| ASSERT(m_initialized) | ||
| REQUIRE(m_initialized, "Transformer has not been fitted.\n"); |
There was a problem hiding this comment.
shouldn't we use a different exception type other than ShogunException
| SGVector<float64_t> CPruneVarSubMean::apply_to_feature_vector(SGVector<float64_t> vector) | ||
| { | ||
| float64_t* ret=NULL; | ||
| REQUIRE(m_initialized, "Transformer has not been fitted.\n"); |
There was a problem hiding this comment.
shouldn't we use a different exception type other than ShogunException
| MS_NOT_AVAILABLE); | ||
| } | ||
|
|
||
| void CTransformer::check_fitted() const |
There was a problem hiding this comment.
i would rather go with the java like: is_fitted or is_fit depending which english we'd like to go with :) but let's stick to british (non north american english as in case of the exception type naming)
| CTransformer::CTransformer() : CSGObject() | ||
| { | ||
| SG_ADD( | ||
| &m_fitted, "fitted", "Whether the transformer has been fitted.", |
There was a problem hiding this comment.
let's register this param as is_fitted