//-------------------------------- void print_char_line(int line) { if(line>=0 && line<LINES_PER_CHAR) { print_pixels(spf_char[line]); } }
void run_learn_predict_test(bool& ok) { test_tool t("test/digits/learn_predict", ok); typedef recognition_problem p; reexp::lang<p> lang; reexp::data<p> data(lang, sample_dim()); setup_reg<p>(lang, data); reexp::stats<p> stats(data); reexp::learner<p> learner(lang, stats); setup_learner(learner); int rounds = 3; for (int i = 0; i < rounds; i++) { float before = stats.ndl(); if (!learner.add_exp()) break; t<<"expression added."<<checkl; float after = stats.ndl(); t<<"info "<<before<<" -> "<<after<<checkl<<checkl; } t<<checkl<<"learning done."<<checkl<<checkl; print_scan(t, lang, stats); reexp::pinfo info; setup_pinfo(info); reexp::lang_info<p> li(info, lang); t<<"vars:\n\n"<<li.drawn_vars_tostring(cvarid::x, cvarid::y); t<<"px"<<checkl<<checkl; print_pixels(t, data.var(varid::pixel)); for (int i = 0; i < rounds; i++) { t<<"exp"<<i<<checkl<<checkl; print_pixels(t, data.var(varid::digit9 + i + 1)); } print_prediction<p>(t, stats); }
void run_learn_picked_predict_test(bool& ok) { test_tool t("test/digits/learn_picked_predict", ok); typedef recognition_problem p; reexp::lang<p> lang; reexp::data<p> data(lang, sample_dim()); setup_reg<p>(lang, data); reexp::stats<p> stats(data); float before = stats.ndl(); lang.add_exp(lang.rel(relid::up_down), 3); float after = stats.ndl(); t<<"info "<<before<<" -> "<<after<<checkl<<checkl; before = after; lang.add_exp(lang.rel(relid::left_right), 3); after = stats.ndl(); t<<"info "<<before<<" -> "<<after<<checkl<<checkl; t<<checkl<<"learning done."<<checkl<<checkl; print_scan(t, lang, stats); reexp::pinfo info; setup_pinfo(info); reexp::lang_info<p> li(info, lang); t<<"vars:\n\n"<<li.drawn_vars_tostring(cvarid::x, cvarid::y); t<<"px"<<checkl<<checkl; print_pixels(t, data.var(varid::pixel)); for (int i = 0; i < 1; i++) { t<<"exp"<<i<<checkl<<checkl; print_pixels(t, data.var(varid::digit9 + i + 1)); } print_prediction<p>(t, stats); }
//-------------------------------- void print_char() { if(output.print_header==1) { print_char_header(); } //using spf_char int k=0; for(k=0;k<LINES_PER_CHAR;k++) { print_pixels(spf_char[k]); printf("\n"); } }