@@ -0,0 +1,1767 @@
+# forward propagation for neural network%0A%0Afrom numpy import *%0Adef neural_forward(xi, input, MEGA_THETA=0):%0A %0A%09# initialise MEGA_THETA if required, run forward prop, give result%0A%09%0A    %09if size(MEGA_THETA) == 1: %0A %09# MEGA_THETA not given, so initialise it%0A       %09%09MEGA_THETA = create_MEGA_THETA(xi)%0A%0A    %09# define subset of MEGA_THETA%0A   %09row_start = 0%0A%09row_end = xi%5B1%5D%0A    %09col_start = 0%0A    %09col_end = xi%5B0%5D + 1%0A    %09%0A    %09# subsets of output vectors a0, a1, a2, .. etc%0A    %09L = size(xi)%09%09%09# layers in NN (including in/out)%0A    %09rows_A = sum(xi) + L -1%09%09%0A    %09A_start_index = 0%0A    %09A_end_index = xi%5B0%5D+1%0A    %09A = zeros(rows_A)%09%09# store output from each layer (row-less) %0A    %09%0A    %09# save input/output vectors into A for backprop%0A    %09a = r_%5Barray(%5B1%5D), input%5D%0A    %09A%5BA_start_index: A_end_index%5D = a%0A         %09%0A    %09for i in range(2,L):%0A        %09# local_theta is theta for layer i-1%0A        %09local_theta = MEGA_THETA%5Brow_start:row_end,col_start:col_end%5D%0A       %09%09a = r_%5Barray(%5B1%5D), g(dot(local_theta,a))%5D%09# add base unit%0A       %09%09A_start_index = A_end_index%0A       %09%09A_end_index = A_start_index + xi%5Bi-1%5D + 1%09# add base unit%0A       %09%09%0A        %09# for local_theta going into next loop%0A        %09row_start = row_end%0A        %09row_end = row_end + xi%5Bi%5D + 1%0A        %09col_start = col_end%0A        %09col_end = col_end + xi%5Bi-1%5D + 1 %0A        %09%0A        %09# save results%0A        %09A%5BA_start_index:A_end_index%5D = a%0A    %09%09%0A    %09# last step due to i=2,3,..,L-1%0A    %09local_theta = MEGA_THETA%5Brow_start:row_end,col_start:col_end%5D%0A    %09a = g(dot(local_theta,a))%0A    %09A%5Brows_A - xi%5B-1%5D:%5D = a%0A    %09return A%0A%0A# # # #%0A%0Adef g(x):%0A%09# sigmoid function for NN nodes%0A%09#g = 1/(1+exp(-x));%0A%09%0A%09# rectified linear units%0A%09g = ones(len(x))*(x%3E0)%0A%09%0A%09# linearised RLUs%0A%09#g = ones(len(x))*(x%3E0)%0A%09return g%0A

Create RLU_neural_forward.py