Nov-02-2018, 12:21 PM
def train(): #random init of weights w1 = np.random.randn() w2 = np.random.randn() b = np.random.randn() iterations = 1000000 learning_rate = 0.01 costs = [] # keep costs during training, see if they go down for i in range(iterations): # get a random point ri = np.random.randint(len(data)) point = data[ri] z = point[0] * w1 + point[1] * w2 + b pred = sigmoid(z) # networks prediction target = point[2] # cost for current random point cost = np.square(pred - target) # print the cost over all data points every 1k iters if i % 100 == 0: c = 0 for j in range(len(data)): p = data[j] p_pred = sigmoid(w1 * p[0] + w2 * p[1] + b) c += np.square(p_pred - p[2]) costs.append(c) dcost_dpred = 2 * (pred - target) dpred_dz = sigmoid_p(z) dz_dw1 = point[0] dz_dw2 = point[1] dz_db = 1 dcost_dz = dcost_dpred * dpred_dz dcost_dw1 = dcost_dz * dz_dw1 dcost_dw2 = dcost_dz * dz_dw2 dcost_db = dcost_dz * dz_db w1 = w1 - learning_rate * dcost_dw1 w2 = w2 - learning_rate * dcost_dw2 b = b - learning_rate * dcost_db return costs, w1, w2, b costs, w1, w2, b = train()Hello All,
I am a new user to Python and have been attempting to develop logistic regressions and Neural Networks in Python over the past few weeks. I've hit a stumbling block with neural networks whereas when trying to handle a large dataset with many inputs i need many weightings, will i have to write them each individually out with the equations as done above for a 2 input model?
Above is for a 2 vraibles, about 8 inputs and 1 output
I want to be able to work with multiple variables, very larger datasets but still aim for 1 output.
Will i need to type our a all the individual weighting equations and such?
Sorry if its not clear.
Cheers,
Chris