I am using matlab to apply a multilayered neural network. In the code I
as the value of each node netValue {k} in the form of the weight between the layer K and K + 1 Weight {K} etc. Since this data is three-dimensional, I have to use the cell to keep the matrix multiplied by placing the 2-D matrix. So to really train the model, really is really slow, which I hope to use from the cell. Can anyone tell me how to speed this code? Thanks You used CLC; close all; Clear all; Input = [-2.4: 2; -2: 0.4: 2]; Ican = 4; Depth = 4; % Total Layer - 1, by Union [Preamble, Pattern] = Size (Input); LevelNum (1) = Feature Number; LevelNum (2) = 5; LevelNum (3) = 5; LevelNum (4) = 5; LevelNum (5) = 2; Weight = cell (0); For K = 1: Depth Weight {k} = Rand (Levellan (K + 1), Levelanum (K) - 2 * Rand (Levnalam (K + 1), Level Nom (K)); Threshold {k} = Rand (Levellanum (K + 1), 1) - 2 * Rand (Levelanum (K + 1), 1); End Runcount = 0; SumMSE = 1;% Init MSE minError = 1e-5; Afa = 0.1; "Gradient Edendas "% Of the training loop, while the (% counts & lt; 100000 & amp; sumMSE & gt; minError) sumMSE = 0;% of the MSE for I = 1: Sample% sample loop net value {1} = input (: , I); for k = 2: depth pure value {k} = weight {k-1} * s Predictive {k-1} + threshold {k-1};% calculates each layer with a pure value {k} = 1 ./ (1 + exp (-netValue {k});% Logistic Function End NetValue Apply {Depth = 1} = weight {depth} * netValue {depth} + threshold (depth);% output layer e = 1 + sin ((pi / 4) * ican * netValue {1}) - Netval {Depth + 1};% Calc error assistance help {depth} = diagonals (ones (size (net value {depth + 1}); s {depth} = -2 * assisters {depth} * e = k = depth - 1: -1: 1 Support S {k} = Diag ((1-Netview {k + 1}) * Netview {k + 1}); S {k} = assistS {k} * weight {k + 1} '* s {k + 1}; End depth weight for K = 1 {k} = weight {k} - afa * s {k} * netValue {k} '; Threshold {k} = threshold {k} - fa * s {k}; Closing sumMSE = sumMSE + E '* E; Closing sumMSE = sqrt / sample; RunCount = runCount + 1; End x = [-2: 0.1: 2; -2: 0.1: 2]; Y = zero (size (x)); Z = 1 + sin ((pi / 4) * ican. * X); % Test for I = 1: length (x) purified {1} = x (:, i); For k = 2: depth pure value {k} = weight {k-1} * purified {k-1} + threshold {k-1}; NetWell {k} = 1 ./ (1 + APP (-Nnet {k})); End y (:, i) = weight (depth) * purple (depth) + threshold (depth); End plot (X (1, :), Y (1, :), 'R'); Wait; Plot (X (1, :), Z (1, :), 'G'); Hold down;
profiler to use it Is your code really slowing down? It shows which lines take the most time to execute.
No comments:
Post a Comment