This is a static copy of a profile report

Home

Function details for CGThis is a static copy of a profile report

Home

CG (Calls: 5, Time: 656.774 s)
Generated 19-Jun-2021 04:39:10 using performance time.
function in file /nfs/inm_phd/07/d07944009/2021/0618-proj6/simpleNN/MATLAB/opt/CG.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
newtonfunction5
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
26
Gv = JTBJv(data, param, model,...
72431.985 s65.8%
21
net = Jacobian(data, param, mo...
5219.889 s33.5%
48
sGs = s' * (-g - r - param.lam...
54.809 s0.7%
30
Gv = (param.lambda + 1/param.C...
720.022 s0.0%
32
alpha = rTr / (v' * Gv);
720.014 s0.0%
All other lines  0.055 s0.0%
Totals  656.774 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
CG>JTBJvsubfunction72431.982 s65.8%
Jacobianfunction5219.885 s33.5%
gpufunction150.003 s0.0%
Self time (built-ins, overhead, etc.)  4.904 s0.7%
Totals  656.774 s100% 
Code Analyzer results
Line numberMessage
7The value assigned to variable 'Gv' might be unused.
Coverage results
Show coverage for parent directory
Total lines in function48
Non-code lines (comments, blank lines)10
Code lines (lines that can run)38
Code lines that did run36
Code lines that did not run2
Coverage (did run/can run)94.74 %
Function listing
time 
Calls 
 line
   1 
function [s, CGiter, gs, sGs] = CG(data, param, model, net, grad)
   2 

< 0.001 
      5 
   3
var_ptr = model.var_ptr; 
< 0.001 
      5 
   4
n = var_ptr(end) - 1; 
< 0.001 
      5 
   5
GNsize = size(data, 2); 
  0.002 
      5 
   6
s = gpu(@zeros, [n, 1]); 
  0.002 
      5 
   7
Gv = gpu(@zeros, [n, 1]); 
  0.002 
      5 
   8
g = gpu(@zeros, [n, 1]); 
  0.001 
      5 
   9
for m = 1 : model.L 
  0.002 
     20 
  10
	var_range = var_ptr(m) : var_ptr(m+1) - 1; 
  0.006 
     20 
  11
	g(var_range) = [grad.dfdW{m}(:); grad.dfdb{m}]; 
  0.002 
     20 
  12
end 
  0.001 
      5 
  13
r = -g; 
< 0.001 
      5 
  14
v = r; 
  15 

  0.002 
      5 
  16
gnorm = norm(g); 
< 0.001 
      5 
  17
rTr = gnorm^2; 
< 0.001 
      5 
  18
cgtol = param.xi * gnorm; 
  19 

< 0.001 
      5 
  20
if param.Jacobian 
 219.889 
      5 
  21
	net = Jacobian(data, param, model, net); 
< 0.001 
      5 
  22
end 
  23 

  0.001 
      5 
  24
for CGiter = 1 : param.CGmax 
< 0.001 
     72 
  25
	if param.Jacobian 
 431.985 
     72 
  26
		Gv = JTBJv(data, param, model, net, v); 
  27 
	else
  28 
		Gv = R_JTBJv(data, param, model, net, v);
< 0.001 
     72 
  29
	end 
  0.022 
     72 
  30
	Gv = (param.lambda + 1/param.C) * v + Gv/GNsize; 
  31 

  0.014 
     72 
  32
	alpha = rTr / (v' * Gv); 
  0.007 
     72 
  33
	s = s + alpha * v; 
  0.006 
     72 
  34
	r = r - alpha * Gv; 
  35 

  0.003 
     72 
  36
	rnewTrnew = r' * r; 
  37 
	% Stopping condition
  0.005 
     72 
  38
	if (sqrt(rnewTrnew) <= cgtol) || (CGiter == param.CGmax) 
  0.001 
      5 
  39
		break 
< 0.001 
     67 
  40
	end 
< 0.001 
     67 
  41
	beta = rnewTrnew / rTr; 
< 0.001 
     67 
  42
	rTr = rnewTrnew; 
  0.003 
     67 
  43
	v = r + beta * v; 
< 0.001 
     67 
  44
end 
  45 

  46 
% Values used for predicting function-value reduction
  0.002 
      5 
  47
gs = s' * g; 
  4.809 
      5 
  48
sGs = s' * (-g - r - param.lambda*s); 

Other subfunctions in this file are not included in this listing.