What is the difference between error function and loss function in deep learning? - deep-learning

I was reading about difference between error function and loss function in other questions but I didn't got the clarity what's the exact distance. In laymen term what I understood is error function is used to calculate the distance between predicted and actual output, and loss function is mean of that error function.
Kindly correct if I am wrong. An mathematical answer will be highly appreciated.

Consider an example of root mean squared error which is an error function used to find the difference between actual value and predicted value.
mean squared loss function is used to find the least error in the mean squared error in the given heuristic state space (list of possible models).

Related

I want to resolve the “Error in diag(vcov(object)) : long vectors not supported yet: array.c:2192” error

I have done a multiple regression analysis in lmer.
So I wanted to calculate the confidence interval of the partial regression coefficient using confint(), and when I enter the following code, I get an error "
> confint(H2_FULL, method="Wald")
***Error in diag(vcov(object)) :
long vectors not supported yet: array.c:2192***
" and cannot run it.
Does anyone know how to resolve this error? Please help.
I am a beginner in R. I would appreciate it if you could help me to understand it clearly.
I only need to be able to calculate 95% confidence intervals for the partial regression coefficients of multiple regression analysis(multi-model).
I assume four explanatory variables, which is why I think this error was made.
This error did not occur in the single regression analysis.

Error in solve.default(res$hessian*n.used,A): 'a' must be a complex matrix

I am using the arima function in R's forecast package and I get the following error:
Error in solve.default(res$hessian*n.used,A): 'a' must be a complex matrix
The time series that I am fitting has very large values numbers e.g. greater than 10 million. Can anyone please provide a solution that might alleviate this error? Would scaling the time series help?

lmer Get p values from anova

lmerTest was designed as a wrapper to permit estimation of p-values from lmer mixed model analyses, using the Satterthwaite estimate of denominator degrees of freedom (ddf). But lmerTest now appears to be broken. It presently returns a message that there was an internal calculation error and returns only the lmer result (with no p-values). I have been able to calculate the p-values from the summary() function, using Dan Mirman's excellent code for calculating the Kenward-Rogers estimate of ddf. But I can't find equivalent code to calculate the p-values in an anova call on the lmer model. I suspect that one just needs to feed anova() a ddf, but I can't figure out how to do that.
Thanks in advance to anyone that can suggest solutions for this problem.
Larry Hunsicker
lmerTest returns the anova output of lme4 package whenever some computational error occurs in getting the Satterthwaite's approximation (such as e.g. in calculating the asymptotic variance covariance matrix). The lmerTest is not broken, it is just that there could be examples when the Satterthwaite's approximation cannot be calculated. In my experience this occurs not often.

matlab function which is a function of an intergral

I need to write my own function which has the form f(x,y)=Integrate(g(x,y,z),z from 0 to inf). so the code I used was:
function y=f(x,y)
g=#(z)exp(-z.^2)./(z.^x).*(z.^2+y.^2).^(x/2);% as a function of x,y and z
y=quadgk(g,0,inf)
and if I call it for a single value like f(x0,y0), it works but if I try to calculate something like f([1:10],y0), then the error message says that there is something wrong with the times and dimension. In principle I can use for loops but then my code slows down and takes forever. Is there any help I can get from you guys? or references?
I'm trying to avoid the for loop since in matlab it's much faster to use matrix computation than to use for loop. I wonder if there is any trick that I can take advantage of this feature.
Thanks for any help in advance,
Lynn
Perhaps you can try to transpose the interval, creating row based values instead of column based f([1:10]',y0). Otherwise something in your function might be wrong, for example to get x^y to work with lists as input, you have to prefix with a dot x.^y. The same for mulitply and division I think..
If loop is no problem for you, you should do something like:
function y2=f(x,y)
y2=zeros(size(x));
for n=1:numel(x)
g=#(z)exp(-z.^2)./(z.^x(n)).*(z.^2+y.^2).^(x(n)/2);% as a function of x,y and z
y2(n)=quadgk(g,0,inf)
end
The problem here is that quadk itself uses vectors as argument for g. Then you have in g somethink like z.^x, which is the power of two vectors that is only defined if z and x have the same dimension. But this is not what you want.
I assume that you want to evaluate the function for all arguments in x and that the output vector has the same dimension as x. But this does not seem to be possible since even this simple example
g=#(x)[x;x.^2]
quad(g,0,1)
does not work:
Error using quad (line 79)
The integrand function must return an output vector of the same length as the
input vector.
A similar error shows when using quadgk. The documentation also says that this routine works only for scalar functions and this is not surprising since an adaptive quadrature rule would in general use different points for each function to evaluate the integral.
You have to use quadvinstead, which can integrate vector valued functions. But this gives wrong results since your function is integrated in the interval [0,\infty).

Finding the Maximum

How to find the following Maximum or supremum by computer software such as Mathematica and Matlab: $\sup\frac{(1+s)^{4}+(s+t)^{4}+t^{4}}{1+s^{4}+t^{4}}$?
Instead of numerical approximation, what is the accurate maximum?
Thanks.
Since the question seems a bit like homework, here's an answer that starts a bit like a lecture:
ask yourself what happens to the function as s and t go to small and to large positive and negative values; this will help you to identify the range of values you should be examining; both Mathematica and Matlab can help your figure this out;
draw the graph of your function over the range of values of interest, develop a feel for its shape and try to figure out where it has maxima; for this the Mathematic Plot3D[] function and the Matlab plot() function will both be useful;
since this is a function of 2 variables, you should think about plotting some of its sections, ie hold s (or t) constant, and make a 2D plot of the section function; again, develop some understanding of how the function behaves;
now you should be able to do some kind of search of the s,t values around the maxima of the function and get an acceptably accurate result.
If this is too difficult then you could use the Mathematica function NMaximize[]. I don't think that Matlab has the same functionality for symbolic functions built-in and you'll have to do the computations numerically but the function findmax will help.
In Matlab, one would create a vector/matrix with s and t values, and a corresponding vector with the function values. Then you can pinpoint the maximum using the function max
In Mathematica, use FindMaximum like this:
f[s_,t_]:= ((1+s)^4 + (s+t)^4 + t^4)/(1+s^4+t^4)
FindMaximum[ f[s,t],{s,0},{t,0} ]
This searches for a maximum starting from (s,t)=(0,0).
For more info, see http://reference.wolfram.com/mathematica/ref/FindMaximum.html