What does this mean and how can I get rid of it ?

17 views (last 30 days)
I have build a neural network everything works fine untill I replace my tanh function with LUT. I tried this with different ways too but the errors keeps appearing. This is how I replace it but I really dont know what is wrong.
...
%% Define system behavioral constraints for fixed point conversion
opts=fxpOptimizationOptions();
opts.MaxIterations=25;
opts.addTolerance(system_under_design,1,'RelTol',0.05);
opts.addTolerance(system_under_design,1,'AbsTol',50)
opts.AllowableWordLengths=8:32;
%% Optimize Data Types
solution=fxpopt(model,system_under_design,opts);
best_solution=solution.explore;
%% Replace Activation Function with an optimized LUT
subsystem_path = [system_under_design '/Layer 1/tansig/tanh'];
p = FunctionApproximation.Problem(subsystem_path);
p.Options.WordLengths = 8:32;
p.InputTypes=fixdt(1,16,10);
p.OutputType=fixdt(1,16,15);
p.Options.BreakpointSpecification = 'EvenPow2Spacing';
%% Solve and replace tanh
solution = p.solve;
fxpneuralnetworks.replaceWithLUT(subsystem_path, solution);
set_param([subsystem_path '/LUT'], 'UseLastTableValue', 1);
set_param([subsystem_path '/LUT'], 'DiagnosticForOutOfRangeInput', 'None');
%% Validate model accuracy after look up table replacement
sim_out = sim(model_to_convert, 'SaveFormat', 'Dataset'); %here NOT FINE!!!!
%% Helper functions
% Create a function to plot regression data
function plotRegression(sim_out, baseline_path, neural_network_output_path, plotTitle)
nn_out = find(sim_out.logsout, 'BlockPath', neural_network_output_path);
yarr_out = find(sim_out.logsout, 'BlockPath', baseline_path);
ypred = nn_out{1}.Values.Data;
actual = yarr_out{1}.Values.Data;
figure;
plotregression(double(ypred), actual, plotTitle);
end
%%replaceWithLUT function---MY LUT REPLACEMENT FILE just copy and paste actually is fine too!
function replaceWithLUT(activationFunctionSubsystem, functionApproximationResult)
destinationBlk = activationFunctionSubsystem;
functionApproximationResult.approximate;
sourceBlk = gcb;
approximate_model_name = gcs;
% Get original block position
pos = get_param(destinationBlk, 'Position');
% Delete original block
delete_block(destinationBlk);
% Add approximate in place of original
add_block(sourceBlk, destinationBlk,'Position',pos);
% Ensure that the replaced block is uncommented
set_param(destinationBlk, 'Commented', 'off');
close_system(approximate_model_name, 0);
end
And this is the model on the specific Area of the appearing error. :
So the thing is that after I replaced the tanh block with a LUT Ι get this error
"Inconsistent numeric values for port 1 of ".......DTC1" Outport value (fi(-8.16......,1,16,10)) at major time step 17 is less than maximum (fi(-8,1,16,10)) from SigSpec1.This occurs for element(5)."
Ty in advance,
M

Answers (1)

MathWorks Fixed Point Team
Hello, please refer to this answer for more information on what this error means. Could you please add your model and script you used so we can try to reproduce the issue? Thanks!

Categories

Find more on Manual Performance Optimization in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!