added a preview function for previewing stuff.

parent 33d901de
......@@ -14,6 +14,7 @@ OBJ=bmf.o \
bmf_update_dict.o\
bmf_update_dict_missing_data.o\
bmf_update_coeffs.o\
preview.o
# tests
TESTSRC=$(wildcard *_test.cpp)
......
......@@ -4,6 +4,7 @@
#include "bmf_init.h"
#include "bmf_update_coeffs.h"
#include "bmf_update_dict.h"
#include "preview.h"
double max_err_weight = 0;
size_t max_coef_weight = 0;
......@@ -12,8 +13,9 @@ model_init_algorithm_t initialize_dictionary = initialize_dictionary_neighbor;
coeffs_update_algorithm_t coefficients_update = coefficients_update_omp;
//coeffs_update_algorithm_t coefficients_update = coefficients_update_mob;
dict_update_algorithm_t update_dictionary = update_dictionary;
model_learn_algorithm_t learn_model = learn_model_traditional;
model_learn_algorithm_t learn_model_outer = learn_model_traditional;
model_learn_algorithm_t learn_model_inner = learn_model_traditional;
preview_iter_t preview_iter = preview_none;
model_init_algorithm_t model_init_algorithm_catalog[] = {
initialize_dictionary_neighbor,
......@@ -101,7 +103,7 @@ static int count_options(const char* names[]) {
}
void learn_model_setup(int mi_algo, int es_algo, int du_algo, int lm_algo, int lmi_algo) {
void learn_model_setup(int mi_algo, int es_algo, int du_algo, int lmo_algo, int lmi_algo) {
int n;
n = count_options(model_init_algorithm_names);
if (mi_algo > n) {
......@@ -119,7 +121,7 @@ void learn_model_setup(int mi_algo, int es_algo, int du_algo, int lm_algo, int l
exit(-1);
}
n = count_options(lm_algorithm_names);
if (lm_algo > n) {
if (lmo_algo > n) {
std::cerr << "Invalid model learning algorithm (0-" << n << ')' << std::endl;
exit(-1);
}
......@@ -140,8 +142,8 @@ void learn_model_setup(int mi_algo, int es_algo, int du_algo, int lm_algo, int l
std::cout << "Using " << coeffs_update_algorithm_names[es_algo] << " for coefficients update." << std::endl;
update_dictionary = dict_update_algorithm_catalog[du_algo];
std::cout << "Using " << dict_update_algorithm_names[du_algo] << " for dictionary update." << std::endl;
learn_model = learn_model_algorithm_catalog[lm_algo];
std::cout << "Using " << lm_algorithm_names[lm_algo] << " for outer learning loop." << std::endl;
learn_model_outer = learn_model_algorithm_catalog[lmo_algo];
std::cout << "Using " << lm_algorithm_names[lmo_algo] << " for outer learning loop." << std::endl;
learn_model_inner = learn_model_algorithm_catalog[lmi_algo];
std::cout << "Using " << lm_algorithm_names[lmi_algo] << " for inner learning." << std::endl;
}
......
......@@ -29,11 +29,20 @@ typedef idx_t (*model_learn_algorithm_t)(binary_matrix& X,
binary_matrix& D,
binary_matrix& A);
typedef idx_t (*preview_iter_t)(const binary_matrix& X,
const binary_matrix& H,
const binary_matrix& E,
const binary_matrix& D,
const binary_matrix& A,
const idx_t inner_iter,
const idx_t outer_iter);
extern model_init_algorithm_t initialize_dictionary;
extern coeffs_update_algorithm_t coefficients_update;
extern dict_update_algorithm_t update_dictionary;
extern model_learn_algorithm_t learn_model;
extern model_learn_algorithm_t learn_model_outer;
extern model_learn_algorithm_t learn_model_inner;
extern preview_iter_t preview_iter;
extern const char* model_init_algorithm_names[];
extern const char* coeffs_update_algorithm_names[];
......
......@@ -196,7 +196,7 @@ int main(int argc, char **argv) {
std::cout << "Further adapting dictionary to data." << std::endl;
const idx_t me = cols*error_probability;
set_max_err_weight(me);
learn_model(X,H,E,D,A);
learn_model_outer(X,H,E,D,A);
render_mosaic(D,"denoising_adapted_dictionary.pbm");
//
// 3. denoise: average number of errors in Bernoulli(p) on a
......
......@@ -171,7 +171,7 @@ int main(int argc, char **argv) {
// 2. further update dictionary
//
std::cout << "Further adapting dictionary to data." << std::endl;
learn_model(X,H,E,D,A);
learn_model_outer(X,H,E,D,A);
render_mosaic(D,"denoising_adapted_dictionary.pbm");
//
// 3. denoise: average number of errors in Bernoulli(p) on a
......
......@@ -289,7 +289,7 @@ int main(int argc, char **argv) {
//
// learn model
//
idx_t L = learn_model(X,H,E,D,A);
idx_t L = learn_model_outer(X,H,E,D,A);
//
// write output
//
......
#include "preview.h"
idx_t preview_none( const binary_matrix& X,
const binary_matrix& H,
const binary_matrix& E,
const binary_matrix& D,
const binary_matrix& A,
const idx_t inner_iter,
const idx_t outer_iter) {
return 0;
}
\ No newline at end of file
/**
* \file preview.h
* \brief These functions are called in between iterations to show
* intermediate results in the form of PBM images.
*/
#ifndef PREVIEW_H
#define PREVIEW_H
#include "base_types.h"
#include "pbm.h"
idx_t preview_none( const binary_matrix& X,
const binary_matrix& H,
const binary_matrix& E,
const binary_matrix& D,
const binary_matrix& A,
const idx_t inner_iter,
const idx_t outer_iter);
#endif
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment