minor changes to CLP(BN).
This commit is contained in:
parent
54465b08f1
commit
b2eb437625
@ -476,7 +476,7 @@ clean_up :-
|
|||||||
fail.
|
fail.
|
||||||
clean_up.
|
clean_up.
|
||||||
|
|
||||||
gibbs_params(5,1000,10000).
|
gibbs_params(5,100,1000).
|
||||||
|
|
||||||
cvt2problist([], []).
|
cvt2problist([], []).
|
||||||
cvt2problist([[[_|E]]|Est0], [Ps|Probs]) :-
|
cvt2problist([[[_|E]]|Est0], [Ps|Probs]) :-
|
||||||
|
@ -63,6 +63,8 @@ clpbn_reset_tables(Sz) :-
|
|||||||
myf(Key, Size, Index) :-
|
myf(Key, Size, Index) :-
|
||||||
instantiated_term_hash(Key, -1, Size, Index).
|
instantiated_term_hash(Key, -1, Size, Index).
|
||||||
|
|
||||||
|
myc(A, B) :-
|
||||||
|
ground(A), !, B == A.
|
||||||
myc(A, B) :-
|
myc(A, B) :-
|
||||||
variant(A,B),
|
variant(A,B),
|
||||||
term_variables(A,L1),
|
term_variables(A,L1),
|
||||||
|
@ -97,7 +97,7 @@ run_vel_solver(LVs, LPs, LNVs) :-
|
|||||||
findall(Ps, solve_vel(LVs, LNVs, Ps), LPs).
|
findall(Ps, solve_vel(LVs, LNVs, Ps), LPs).
|
||||||
|
|
||||||
solve_vel([LVs|_], [NVs0|_], Ps) :-
|
solve_vel([LVs|_], [NVs0|_], Ps) :-
|
||||||
length(NVs0, L), (L > 64 -> clpbn_gviz:clpbn2gviz(user_error,sort,NVs0,LVs) ; true ),
|
% length(NVs0, L), (L > 64 -> clpbn_gviz:clpbn2gviz(user_error,sort,NVs0,LVs) ; true ),
|
||||||
find_all_clpbn_vars(NVs0, NVs0, LV0, LVi, Tables0),
|
find_all_clpbn_vars(NVs0, NVs0, LV0, LVi, Tables0),
|
||||||
sort(LV0, LV),
|
sort(LV0, LV),
|
||||||
% construct the graph
|
% construct the graph
|
||||||
|
@ -227,11 +227,10 @@ run_sample([C|Cases], [P|Ps], Table) :-
|
|||||||
run_sample(Cases, Ps, Table).
|
run_sample(Cases, Ps, Table).
|
||||||
|
|
||||||
call_run_all(Mod:Items) :-
|
call_run_all(Mod:Items) :-
|
||||||
clpbn_flag(em_solver, pcg),
|
clpbn_flag(em_solver, pcg), !,
|
||||||
backtrack_run_all(Items, Mod).
|
backtrack_run_all(Items, Mod).
|
||||||
call_run_all(Items) :-
|
call_run_all(Mod:Items) :-
|
||||||
clpbn_flag(em_solver, pcg),
|
run_all(Mod:Items).
|
||||||
run_all(Items).
|
|
||||||
|
|
||||||
backtrack_run_all([Item|_], Mod) :-
|
backtrack_run_all([Item|_], Mod) :-
|
||||||
call(Mod:Item),
|
call(Mod:Item),
|
||||||
|
@ -4,9 +4,20 @@
|
|||||||
|
|
||||||
:- [pos:train].
|
:- [pos:train].
|
||||||
|
|
||||||
:- ['~/Yap/work/CLPBN/clpbn/examples/School/school_32'].
|
:- ['~/Yap/work/packages/CLPBN/clpbn/examples/School/school_32'].
|
||||||
|
|
||||||
:- ['~/Yap/work/CLPBN/learning/em'].
|
:- ['~/Yap/work/packages/CLPBN/learning/em'].
|
||||||
|
|
||||||
|
%:- clpbn:set_clpbn_flag(em_solver,gibbs).
|
||||||
|
:- clpbn:set_clpbn_flag(em_solver,jt).
|
||||||
|
%:- clpbn:set_clpbn_flag(em_solver,vel).
|
||||||
|
|
||||||
|
timed_main :-
|
||||||
|
statistics(runtime, _),
|
||||||
|
findall(X,goal(X),L),
|
||||||
|
em(L,0.01,10,_,Lik),
|
||||||
|
statistics(runtime, [T,_]),
|
||||||
|
format('Took ~d msec and Lik ~3f~n',[T,Lik]).
|
||||||
|
|
||||||
main :-
|
main :-
|
||||||
findall(X,goal(X),L),
|
findall(X,goal(X),L),
|
||||||
@ -14,9 +25,9 @@ main :-
|
|||||||
writeln(Lik:CPTs).
|
writeln(Lik:CPTs).
|
||||||
|
|
||||||
%
|
%
|
||||||
% change to 0.05, 0.1, 0.2 to make things simpler/harder
|
% change to 0.0, 0.1, 0.2 to make things simpler/harder
|
||||||
%
|
%
|
||||||
missing(0.3).
|
missing(0.50).
|
||||||
|
|
||||||
% miss 30% of the examples.
|
% miss 30% of the examples.
|
||||||
goal(professor_ability(P,V)) :-
|
goal(professor_ability(P,V)) :-
|
||||||
|
@ -30,15 +30,15 @@
|
|||||||
|
|
||||||
run_all([]).
|
run_all([]).
|
||||||
run_all([G|Gs]) :-
|
run_all([G|Gs]) :-
|
||||||
call(G),
|
run_all(user:[G:Gs]).
|
||||||
run_all(Gs).
|
|
||||||
run_all(M:Gs) :-
|
run_all(M:Gs) :-
|
||||||
clpbn_reset_tables,
|
clpbn_reset_tables,
|
||||||
run_all(Gs,M).
|
run_all(Gs,M).
|
||||||
|
|
||||||
run_all([],_).
|
run_all([],_).
|
||||||
run_all([G|Gs],M) :-
|
run_all([G|Gs],M) :-
|
||||||
( call(M:G) -> true ; writeln(bad:M:G), break),
|
% (G = _:ge(ybr136w,t8,23,-1) -> nb_getval(clpbn_tables, Tab), writeln(Tab) ; true ),
|
||||||
|
( call(M:G) -> true ; writeln(bad:M:G), start_low_level_trace, M:G ; halt ),
|
||||||
run_all(Gs,M).
|
run_all(Gs,M).
|
||||||
|
|
||||||
clpbn_vars(Vs,BVars) :-
|
clpbn_vars(Vs,BVars) :-
|
||||||
|
Reference in New Issue
Block a user