diff options
author | graehl <graehl@gmail.com> | 2015-06-26 12:49:59 +0300 |
---|---|---|
committer | graehl <graehl@gmail.com> | 2015-06-26 12:49:59 +0300 |
commit | c461c4ad7232274dab8405b736bb1ac55cc7874d (patch) | |
tree | 45872fc848d3729e8632af0ffdc431726e39e7a2 | |
parent | 82aaac92cc138b16b4bc9ff06056bb985b4166d6 (diff) |
find_string
-rw-r--r-- | src/find_string.hpp | 12 | ||||
-rw-r--r-- | src/neuralClasses.h | 20 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/find_string.hpp b/src/find_string.hpp index fd612fd..d26f6fe 100644 --- a/src/find_string.hpp +++ b/src/find_string.hpp @@ -74,4 +74,16 @@ typename UnorderedMap::iterator find_string(UnorderedMap& map, Slice const& key) return map.find(key, slice_or_string_hash(), slice_or_string_eq()); } + +template <class UnorderedMap, class Slice> +typename UnorderedMap::const_iterator find_string(UnorderedMap const& map, char const* key) { + return map.find(std::pair<char const*, char const*>(key, key+std::strlen(key)), slice_or_string_hash(), slice_or_string_eq()); +} + +/// \return map.find(std:string(key.first, key.second)) but faster +template <class UnorderedMap, class Slice> +typename UnorderedMap::iterator find_string(UnorderedMap& map, char const* key) { + return map.find(std::pair<char const*, char const*>(key, key+std::strlen(key)), slice_or_string_hash(), slice_or_string_eq()); +} + #endif diff --git a/src/neuralClasses.h b/src/neuralClasses.h index 7c86694..458f80e 100644 --- a/src/neuralClasses.h +++ b/src/neuralClasses.h @@ -357,6 +357,26 @@ class Output_word_embeddings { UNCONST(DerivedOut, output, my_output); my_output = ((*W) * input).colwise() + b; + /* TODO: without EIGEN_NO_DEBUG - is this a bug? + ProductBase.h:102: Eigen::ProductBase<Derived, Lhs, Rhs>::ProductBase(const Lhs& + , const Rhs&) [with Derived = Eigen::GeneralProduct<Eigen::Matrix<double, -1, -1 + , 1>, Eigen::Matrix<double, -1, -1>, 5>; Lhs = Eigen::Matrix<double, -1, -1, 1>; + Rhs = Eigen::Matrix<double, -1, -1>]: Assertion `a_lhs.cols() == a_rhs.rows() & + & "invalid matrix product" && "if you wanted a coeff-wise or a dot product use t + he respective explicit functions"' failed. + + (gdb) p a_lhs.cols() + $3 = 50 + (gdb) p a_rhs.rows() + $4 = 100 + + (gdb) p a_lhs.rows() + $5 = 2 + (gdb) p a_rhs.cols() + $6 = 1 + + from lookup_ngram normalization prop.skip_hidden in neuralNetwork.h:100 + */ } // Sparse output version |