Example #1
0
// Getter for the value.
STRING ParamContent::GetValue() const {
  STRING result;
  if (param_type_ == VT_INTEGER) {
    result.add_str_int("", *iIt);
  } else if (param_type_ == VT_BOOLEAN) {
    result.add_str_int("", *bIt);
  } else if (param_type_ == VT_DOUBLE) {
    result.add_str_double("", *dIt);
  } else if (param_type_ == VT_STRING) {
    if (STRING(*(sIt)).string() != nullptr) {
      result = sIt->string();
    } else {
      result = "Null";
    }
  }
  return result;
}
Example #2
0
// Returns a string listing the classes/fonts in a shape.
STRING ShapeTable::DebugStr(int shape_id) const {
  if (shape_id < 0 || shape_id >= shape_table_.size())
    return STRING("INVALID_UNICHAR_ID");
  const Shape& shape = GetShape(shape_id);
  STRING result;
  result.add_str_int("Shape", shape_id);
  if (shape.size() > 100) {
    result.add_str_int(" Num unichars=", shape.size());
    return result;
  }
  for (int c = 0; c < shape.size(); ++c) {
    result.add_str_int(" c_id=", shape[c].unichar_id);
    result += "=";
    result += unicharset_->id_to_unichar(shape[c].unichar_id);
    if (shape.size() < 10) {
      result.add_str_int(", ", shape[c].font_ids.size());
      result += " fonts =";
      int num_fonts = shape[c].font_ids.size();
      if (num_fonts > 10) {
        result.add_str_int(" ", shape[c].font_ids[0]);
        result.add_str_int(" ... ", shape[c].font_ids[num_fonts - 1]);
      } else {
        for (int f = 0; f < num_fonts; ++f) {
          result.add_str_int(" ", shape[c].font_ids[f]);
        }
      }
    }
  }
  return result;
}
Example #3
0
// Returns a debug string summarizing the table.
STRING ShapeTable::SummaryStr() const {
  int max_unichars = 0;
  int num_multi_shapes = 0;
  int num_master_shapes = 0;
  for (int s = 0; s < shape_table_.size(); ++s) {
    if (MasterDestinationIndex(s) != s) continue;
    ++num_master_shapes;
    int shape_size = GetShape(s).size();
    if (shape_size > 1)
      ++num_multi_shapes;
    if (shape_size > max_unichars)
      max_unichars = shape_size;
  }
  STRING result;
  result.add_str_int("Number of shapes = ", num_master_shapes);
  result.add_str_int(" max unichars = ", max_unichars);
  result.add_str_int(" number with multiple unichars = ", num_multi_shapes);
  return result;
}
Example #4
0
// Sets up the network for training using the given weight_range.
void LSTM::DebugWeights() {
  for (int w = 0; w < WT_COUNT; ++w) {
    if (w == GFS && !Is2D()) continue;
    STRING msg = name_;
    msg.add_str_int(" Gate weights ", w);
    gate_weights_[w].Debug2D(msg.string());
  }
  if (softmax_ != NULL) {
    softmax_->DebugWeights();
  }
}