x = linspace(0, 1, 1001);
plot(x, y, 'linewidth', 1.5), grid on
plot( bias(1), bias(2), 'p', 'linewidth', 1.5, 'markersize', 15)
plot([bias(1), bias(1)+in1(1)], [bias(2), bias(2)+in1(2)], '--', 'linewidth', 1.5)
plot([bias(1), bias(1)+in2(1)], [bias(2), bias(2)+in2(2)], '--', 'linewidth', 1.5)
xlabel({'$x$'}, 'interpreter', 'latex', 'fontsize', 14);
ylabel({'$y$'}, 'interpreter', 'latex', 'fontsize', 14);
title({'Target function: $y = \sqrt[4]{x}$'}, 'interpreter', 'latex', 'fontsize', 14);
knob = fmincon(costfun, k0)
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.
plot(x, [f1; f2], 'linewidth', 1.5), grid on
legend({'$f_{1}$', '$f_{2}$'}, 'interpreter', 'latex', 'location', 'east', 'fontsize', 14)
xlabel({'$x$'}, 'interpreter', 'latex', 'fontsize', 14);
ylabel({'$\mathbf{f}$'}, 'interpreter', 'latex', 'fontsize', 14);
title({'Initial activation functions'}, 'interpreter', 'latex', 'fontsize', 14);
plot(x, [f1; f2], 'linewidth', 1.5), grid on
legend({'$f_{1}$', '$f_{2}$'}, 'interpreter', 'latex', 'location', 'best', 'fontsize', 14)
xlabel({'$x$'}, 'interpreter', 'latex', 'fontsize', 14);
ylabel({'$\mathbf{f}$'}, 'interpreter', 'latex', 'fontsize', 14);
title({'Optimized activation functions'}, 'interpreter', 'latex', 'fontsize', 14);
xout = f1*in1(1) + f2*in2(1) + bias(1);
yout = f1*in1(2) + f2*in2(2) + bias(2);
plot(x, y , 'linewidth', 1.5), hold on
plot(xout, yout, 'linewidth', 1.5), grid on, grid minor, hold off
legend({'$\sqrt[4]{x}$', '$\mathcal{N}(x)$'}, 'interpreter', 'latex', 'location', 'best', 'fontsize', 14)
xlabel({'$x$'}, 'interpreter', 'latex', 'fontsize', 14);
ylabel({'$y$'}, 'interpreter', 'latex', 'fontsize', 14);
title({'Approximation of $\sqrt[4]{x}$'}, 'interpreter', 'latex', 'fontsize', 14);
x = linspace(0, 1, 1001);
xout = f1*in1(1) + f2*in2(1) + bias(1);
yout = f1*in1(2) + f2*in2(2) + bias(2);
error = power(xout, 1/4) - yout;