Skip to content

Commit

Permalink
Optimisation of display (#73)
Browse files Browse the repository at this point in the history
* improves performances of display
* catch error on closing display during inversion
* fix issue #72 when isYout is set for categorical
  • Loading branch information
lionel-rigoux authored Mar 30, 2019
1 parent 70cd0f1 commit cdf5d7f
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 428 deletions.
23 changes: 12 additions & 11 deletions VBA_NLStateSpaceModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -277,24 +277,16 @@
try
delete(intersect(findobj('tag','diagnostics_tabs'),get(options.display.hfp,'children')));
end
VBA_updateDisplay(posterior,suffStat,options,y,0,'precisions')
if dim.n_phi > 0
VBA_updateDisplay(posterior,suffStat,options,y,0,'phi')
end
if dim.n > 0
VBA_updateDisplay(posterior,suffStat,options,y,0,'X')
end
if dim.n_theta > 0
VBA_updateDisplay(posterior,suffStat,options,y,0,'theta')
end
VBA_updateDisplay(posterior,suffStat,options,y,0)


%------------------------------------------------------------%
%----------------- Main VB learning scheme ------------------%
%------------------------------------------------------------%

stop = it>=options.MaxIter; % flag for exiting VB scheme
while ~stop

try
it = it +1; % iteration index
F0 = suffStat.F(end);

Expand Down Expand Up @@ -351,6 +343,15 @@
end
end

catch err
switch err.identifier
case 'MATLAB:class:InvalidHandle'
[options] = VBA_initDisplay(options);
continue;
otherwise
rethrow(err);
end
end
end


Expand Down
77 changes: 9 additions & 68 deletions VBA_ReDisplay.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,29 +189,9 @@ function myDeterministic(hfig)
hfig = options.display.hfp;
drawnow

% Display data and hidden states (if any)
% Display
if options.dim.n > 0
VBA_updateDisplay(posterior,suffStat,options,y,0,'X')
end

% Display precision hyperparameters
VBA_updateDisplay(posterior,suffStat,options,y,0,'precisions')
if ~options.OnLine && any([options.sources.type]==0)
xlabel(options.display.ha(6),' ')
if numel(options.display.ha)>7 && ishghandle(options.display.ha(8))
xlabel(options.display.ha(8),' ')
end
end

% Display model evidence
VBA_updateDisplay(posterior,suffStat,options,y,0,'F')

% Display parameters
if dim.n_theta >= 1
VBA_updateDisplay(posterior,suffStat,options,y,0,'theta')
end
if dim.n_phi >= 1
VBA_updateDisplay(posterior,suffStat,options,y,0,'phi')
VBA_updateDisplay(posterior,suffStat,options,y,0)
end

try, VBA_getSubplots (); end
Expand Down Expand Up @@ -264,31 +244,9 @@ function myPriors(hfig)
delete(options.display.hm)
delete(options.display.ho)

% Display data and hidden states (if any)
if options.dim.n > 0
options.OnLine = 0;
VBA_updateDisplay(posterior,suffStat,options,y,0,'X')
end

% Display precision hyperparameters
VBA_updateDisplay(posterior,suffStat,options,y,0,'precisions')
if ~options.OnLine && any([options.sources.type]==0)
xlabel(options.display.ha(6),' ') ;
if numel(options.display.ha)>7 && ishghandle(options.display.ha(8))
xlabel(options.display.ha(8),' ') ;
end
end

% Display model evidence
VBA_updateDisplay(posterior,suffStat,options,y,0,'F')

% Display parameters
if dim.n_theta >= 1
VBA_updateDisplay(posterior,suffStat,options,y,0,'theta')
end
if dim.n_phi >= 1
VBA_updateDisplay(posterior,suffStat,options,y,0,'phi')
end
% Display
options.OnLine = 0;
VBA_updateDisplay(posterior,suffStat,options,y,0)

try, VBA_getSubplots (); end

Expand Down Expand Up @@ -600,27 +558,10 @@ function myVB(hfig)

hfig = options.display.hfp;
drawnow
% Display data and hidden states (if any)
if options.dim.n > 0
VBA_updateDisplay(posterior,suffStat,options,y,0,'X')
end
% Display precision hyperparameters
VBA_updateDisplay(posterior,suffStat,options,y,0,'precisions')
if ~options.OnLine && sum([options.sources(:).type]==0) > 0
xlabel(options.display.ha(6),' ')
if numel(options.display.ha)>7 && ishghandle(options.display.ha(8))
xlabel(options.display.ha(8),' ')
end
end
% Display model evidence
VBA_updateDisplay(posterior,suffStat,options,y,0,'F')
% Display parameters
if dim.n_theta >= 1
VBA_updateDisplay(posterior,suffStat,options,y,0,'theta')
end
if dim.n_phi >= 1
VBA_updateDisplay(posterior,suffStat,options,y,0,'phi')
end

% Display
VBA_updateDisplay(posterior,suffStat,options,y,0)

try VBA_getSubplots (); end


Expand Down
1 change: 1 addition & 0 deletions core/VBA_odeLim2NLSS.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
dim = options.inG.old.dim;
options = options.inG.old.options;
try; options.init = options0.init; end
try; options.display = options0.display; end

% Recover observation parameters posterior
if dim.n_phi > 0
Expand Down
5 changes: 3 additions & 2 deletions core/display/VBA_Bin2Cont.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
% - gridg/stdy: the average (standard deviation, resp.) of conditional
% likelihoods within each partition cell

y = VBA_vec(y(~isnan(y)));
gx = VBA_vec(gx(~isnan(gx)));

if isempty(gx)
stacky = [];
stdy = [];
Expand All @@ -22,8 +25,6 @@
return
end

y = y(:);
gx = gx(:);
ny = numel(y);
try;maxn;catch;maxn=min([floor(ny/2),8]);end
ne = min([maxn,ny]);
Expand Down
2 changes: 2 additions & 0 deletions core/display/VBA_initDisplay.m
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@
styleLabel(xlabel(h,x_label_str));
styleLabel(ylabel(h,y_label_str));

plotUncertainTimeSeries(zeros(options.dim.n_phi,1),zeros(options.dim.n_phi,1),1,h);

end
display.ha(5) = h;

Expand Down
Loading

0 comments on commit cdf5d7f

Please sign in to comment.