
function cost = jota( X, Y, Thetas, lambda = 0 )
   L = length(Thetas) + 1;

   % Regularizacao
   regul = 0;
   for m = 1:L-1,
      regul += sum(sum(Thetas{m} .^ 2));
   end

   m = size(X, 1);
   regul *= lambda / (2*m);

   % Custo
   cost = 0;
   for i = 1:m,
      x = X(i,:)'; 
      y = Y(i,:)';

      hTheta = forwardProp( x, Thetas);

      cost += sum( y .* log(hTheta) + (1-y) .* log(1-hTheta));
   end
   cost = - cost / m + regul;
end
