[&input_layer_name](std::shared_ptr<nntrainer::LayerNode> node) {
return istrequal(node.get()->getName(), input_layer_name);
});
+
if (input_later_node_iterator != representation.end()) {
auto input_layer_node = input_later_node_iterator->get();
- tf_node->setArg(index, layer_to_tf.find(input_layer_node)->second);
+ if (layer_to_tf.find(input_layer_node) != layer_to_tf.end()) {
+ tf_node->setArg(index, layer_to_tf.find(input_layer_node)->second);
+ }
}
}
}
node->calcGradient();
/**
- * If optimization off, or gradient must be applied, then this will be true
+ * If optimization off, or gradient must be applied, then this will be
+ * true
* @todo This apply gradient should be passed to the each weight and later
* be queried when updating gradient at once. (after moving apply_gradient
* out of this function)
*/
// auto &layer = node->getObject();
// apply_gradient = dynamic_training_opt.checkIfApply(
- // layer->getWeightsRef(), layer->net_input[0], layer->net_hidden[0], opt,
- // iteration);
+ // layer->getWeightsRef(), layer->net_input[0], layer->net_hidden[0],
+ // opt, iteration);
/** If gradient must be applied and its not gradient mode, calculate
* gradient
auto train_epoch_end = [this, stop_cb, user_data](RunStats &stat,
DataBuffer &buffer) {
- stat.loss /= static_cast<float>(stat.num_iterations);
+ if (stat.num_iterations != 0) {
+ stat.loss /= static_cast<float>(stat.num_iterations);
+ } else {
+ std::cerr << "stat.num_iterations is 0" << std::endl;
+ return;
+ }
auto &save_path = std::get<props::SavePath>(model_flex_props);
if (!stop_cb(user_data)) {
if (!save_path.empty()) {
auto eval_epoch_end = [this, batch_size, max_acc = 0.0f,
min_loss = std::numeric_limits<float>::max()](
RunStats &stat, DataBuffer &buffer) mutable {
- stat.loss /= static_cast<float>(stat.num_iterations);
+ if (stat.num_iterations != 0) {
+ stat.loss /= static_cast<float>(stat.num_iterations);
+ } else {
+ std::cerr << "stat.num_iterations is 0" << std::endl;
+ return;
+ }
stat.accuracy = stat.num_correct_predictions /
static_cast<float>(stat.num_iterations * batch_size) *
100.0f;
if (time_iter == time_taken.end()) {
reset(time_item, str);
time_iter = time_taken.find(time_item);
+ if (time_iter == time_taken.end()) {
+ throw std::runtime_error("Couldn't find time_iter.");
+ }
}
auto &cnt_ = std::get<GenericProfileListener::CNT>(time_iter->second);
for (auto &[item, time] : time_taken) {
auto title = names.find(item);
-#ifdef DEBUG
if (title == names.end())
throw std::runtime_error("Couldn't find name. it's already removed.");
-#endif
column_size[0] =
std::max(column_size[0], static_cast<unsigned int>(title->second.size()));
}
auto end = std::chrono::steady_clock::now();
auto found = allocates.find(ptr);
-#ifdef DEBUG
if (found == allocates.end())
throw std::invalid_argument("memory profiler didn't allocated");
-#endif
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
end - std::get<timepoint>(found->second));