Skip to content
Snippets Groups Projects
Commit d8964edd authored by Franck Dary's avatar Franck Dary
Browse files

Fixed one hot handling

parent b2f49689
No related branches found
No related tags found
No related merge requests found
...@@ -152,7 +152,7 @@ dynet::Expression MLP::featValue2Expression(dynet::ComputationGraph & cg, const ...@@ -152,7 +152,7 @@ dynet::Expression MLP::featValue2Expression(dynet::ComputationGraph & cg, const
auto & ptr2index = lookupParameters[dict].second; auto & ptr2index = lookupParameters[dict].second;
auto & lu = lookupParameters[dict].first; auto & lu = lookupParameters[dict].first;
bool isConst = fv.policy == FeatureModel::Policy::Final; bool isConst = (fv.policy == FeatureModel::Policy::Final) || (dict->mode == Dict::Mode::OneHot);
auto it = ptr2index.find(fv.vec); auto it = ptr2index.find(fv.vec);
......
...@@ -139,6 +139,10 @@ FeatureModel::FeatureValue FeatureBank::getLength(Config & config, const Feature ...@@ -139,6 +139,10 @@ FeatureModel::FeatureValue FeatureBank::getLength(Config & config, const Feature
if(*fv.value == Dict::nullValueStr) if(*fv.value == Dict::nullValueStr)
return {dict, fv.name, &Dict::nullValueStr, dict->getNullValue(), policy}; return {dict, fv.name, &Dict::nullValueStr, dict->getNullValue(), policy};
int limit = 7;
if (len > limit)
len = limit;
const std::string * str = dict->getStr(std::to_string(len)); const std::string * str = dict->getStr(std::to_string(len));
return {dict, fv.name, str, dict->getValue(*str), policy}; return {dict, fv.name, str, dict->getValue(*str), policy};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment