update in learning
This commit is contained in:
parent
60df0028fb
commit
d750a5d5a2
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
%
|
%
|
||||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
% $Date: 2010-09-29 13:24:43 +0200 (Wed, 29 Sep 2010) $
|
||||||
% $Revision: 4838 $
|
% $Revision: 4845 $
|
||||||
%
|
%
|
||||||
% This file is part of ProbLog
|
% This file is part of ProbLog
|
||||||
% http://dtai.cs.kuleuven.be/problog
|
% http://dtai.cs.kuleuven.be/problog
|
||||||
@ -278,6 +278,7 @@ empty_output_directory :-
|
|||||||
%========================================================================
|
%========================================================================
|
||||||
|
|
||||||
delete_file_silent(File) :-
|
delete_file_silent(File) :-
|
||||||
|
file_exists(File),
|
||||||
delete_file(File),
|
delete_file(File),
|
||||||
!.
|
!.
|
||||||
delete_file_silent(_).
|
delete_file_silent(_).
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
% will run 20 iterations of learning with default settings
|
% will run 20 iterations of learning with default settings
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
:- use_module('../problog').
|
||||||
:- use_module('../problog_learning').
|
:- use_module('../problog_learning').
|
||||||
|
|
||||||
%%%%
|
%%%%
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
%
|
%
|
||||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
% $Date: 2010-09-29 14:52:00 +0200 (Wed, 29 Sep 2010) $
|
||||||
% $Revision: 4838 $
|
% $Revision: 4853 $
|
||||||
%
|
%
|
||||||
% This file is part of ProbLog
|
% This file is part of ProbLog
|
||||||
% http://dtai.cs.kuleuven.be/problog
|
% http://dtai.cs.kuleuven.be/problog
|
||||||
@ -206,15 +206,7 @@
|
|||||||
|
|
||||||
|
|
||||||
:- module(learning,[do_learning/1,
|
:- module(learning,[do_learning/1,
|
||||||
do_learning/2,
|
do_learning/2
|
||||||
set_learning_flag/2,
|
|
||||||
learning_flag/2,
|
|
||||||
learning_flags/0,
|
|
||||||
problog_help/0,
|
|
||||||
set_problog_flag/2,
|
|
||||||
problog_flag/2,
|
|
||||||
problog_flags/0,
|
|
||||||
auto_alpha/0
|
|
||||||
]).
|
]).
|
||||||
|
|
||||||
% switch on all the checks to reduce bug searching time
|
% switch on all the checks to reduce bug searching time
|
||||||
@ -223,7 +215,6 @@
|
|||||||
|
|
||||||
% load modules from the YAP library
|
% load modules from the YAP library
|
||||||
:- use_module(library(lists), [max_list/2, min_list/2, sum_list/2]).
|
:- use_module(library(lists), [max_list/2, min_list/2, sum_list/2]).
|
||||||
:- use_module(library(random)). % PM doesn't seem to be used!
|
|
||||||
:- use_module(library(system), [delete_file/1, file_exists/1, shell/2]).
|
:- use_module(library(system), [delete_file/1, file_exists/1, shell/2]).
|
||||||
|
|
||||||
% load our own modules
|
% load our own modules
|
||||||
@ -438,7 +429,7 @@ do_learning(Iterations,Epsilon) :-
|
|||||||
Iterations>0,
|
Iterations>0,
|
||||||
do_learning_intern(Iterations,Epsilon).
|
do_learning_intern(Iterations,Epsilon).
|
||||||
do_learning(_,_) :-
|
do_learning(_,_) :-
|
||||||
format(user_error,'~n~nWarning: No training examples specified !!!~n~n',[]).
|
format(user_error,'~n~Error: No training examples specified.~n~n',[]).
|
||||||
|
|
||||||
|
|
||||||
do_learning_intern(0,_) :-
|
do_learning_intern(0,_) :-
|
||||||
@ -448,9 +439,7 @@ do_learning_intern(Iterations,Epsilon) :-
|
|||||||
|
|
||||||
init_learning,
|
init_learning,
|
||||||
current_iteration(CurrentIteration),
|
current_iteration(CurrentIteration),
|
||||||
!,
|
|
||||||
retractall(current_iteration(_)),
|
retractall(current_iteration(_)),
|
||||||
!,
|
|
||||||
NextIteration is CurrentIteration+1,
|
NextIteration is CurrentIteration+1,
|
||||||
assertz(current_iteration(NextIteration)),
|
assertz(current_iteration(NextIteration)),
|
||||||
EndIteration is CurrentIteration+Iterations-1,
|
EndIteration is CurrentIteration+Iterations-1,
|
||||||
@ -461,7 +450,7 @@ do_learning_intern(Iterations,Epsilon) :-
|
|||||||
logger_start_timer(duration),
|
logger_start_timer(duration),
|
||||||
|
|
||||||
mse_testset,
|
mse_testset,
|
||||||
once(ground_truth_difference),
|
ground_truth_difference,
|
||||||
gradient_descent,
|
gradient_descent,
|
||||||
|
|
||||||
problog_flag(log_frequency,Log_Frequency),
|
problog_flag(log_frequency,Log_Frequency),
|
||||||
@ -501,8 +490,8 @@ do_learning_intern(Iterations,Epsilon) :-
|
|||||||
retractall(values_correct),
|
retractall(values_correct),
|
||||||
retractall(query_is_similar(_,_)),
|
retractall(query_is_similar(_,_)),
|
||||||
retractall(query_md5(_,_,_)),
|
retractall(query_md5(_,_,_)),
|
||||||
once(empty_bdd_directory),
|
empty_bdd_directory,
|
||||||
once(init_queries)
|
init_queries
|
||||||
); true
|
); true
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -754,13 +743,8 @@ update_values :-
|
|||||||
% start write current probabilities to file
|
% start write current probabilities to file
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
bdd_input_file(Probabilities_File),
|
bdd_input_file(Probabilities_File),
|
||||||
(
|
delete_file_silent(Probabilities_File),
|
||||||
file_exists(Probabilities_File)
|
|
||||||
->
|
|
||||||
delete_file(Probabilities_File);
|
|
||||||
true
|
|
||||||
),
|
|
||||||
|
|
||||||
open(Probabilities_File,'write',Handle),
|
open(Probabilities_File,'write',Handle),
|
||||||
|
|
||||||
( % go over all probabilistic facts
|
( % go over all probabilistic facts
|
||||||
@ -1623,7 +1607,7 @@ auto_alpha :-
|
|||||||
|
|
||||||
%========================================================================
|
%========================================================================
|
||||||
%= initialize the logger module and set the flags for learning
|
%= initialize the logger module and set the flags for learning
|
||||||
%= don't change anything here! use set_learning_flag/2 instead
|
%= don't change anything here! use set_problog_flag/2 instead
|
||||||
%========================================================================
|
%========================================================================
|
||||||
|
|
||||||
init_flags :-
|
init_flags :-
|
||||||
|
Reference in New Issue
Block a user