Hi,
I tried to plot the accuracy and Cost against no of iterations for cat picture predictions for multi-layer neural network. I used below code :
layers_dims = [12288, 20, 7, 5, 1]
variables=[500,700,1000,1500,2000,2500,3000,3500,4000,4500]
trains=[]
tests=[]
trains_costs=[]
tests_costs=[]
for v in variables:
layers_dims = [12288, 20, 7, 5, 1]
parameters = L_layer_model(train_x, train_y, layers_dims, num_iterations = v,learning_rate=0.01)
train_AL,c=L_model_forward(train_x,parameters)
test_AL,c1=L_model_forward(test_x,parameters)
trains_costs.append(compute_cost(train_AL,train_y))
tests_costs.append(compute_cost(test_AL,test_y))
trains.append(np.sum(predict(train_x, train_y, parameters)==train_y)/train_y.shape[1])
tests.append(np.sum(predict(test_x, test_y, parameters)==test_y)/test_y.shape[1])
pred_test = predict(test_x, test_y, parameters)
plt.plot(variables,trains)
plt.plot(variables,tests)
plt.show()
plt.plot(variables,trains_costs)
plt.plot(variables,tests_costs)
plt.show()
I got below graphs with costs and accuracies plotted against no of iterations
As we can see here, though cost for test data dips at 750 iterations and then increases till 4500, accuracy is 0.8 and then dips at 1000 and then further it increases to 0.84 around 2500.
Could anyone please help me understand this graph?
- Does it mean that we should use iterations=750 for this model and ignore higher accuracy as cost for test data is increasing?
- Does it mean that after 1000 iterations, the model is over-fitting?
Thanks in advance