Week 3 exercise 9, why use X.T in predict(parameters, x)

I am OK to finish the exercise but don’t understand when using the predict function, X needs to be transformed.

plt.figure(figsize=(16, 32))
hidden_layer_sizes = [1, 2, 3, 4, 5, 20, 50]
for i, n_h in enumerate(hidden_layer_sizes):
    plt.subplot(5, 2, i+1)
    plt.title('Hidden Layer of size %d' % n_h)
    parameters = nn_model(X, Y, n_h, num_iterations = 5000)
    plot_decision_boundary(lambda x: predict(parameters, x.T), X, Y)
    predictions = predict(parameters, X)
    accuracy = float((np.dot(Y,predictions.T) + np.dot(1 - Y, 1 - predictions.T)) / float(Y.size)*100)
    print ("Accuracy for {} hidden units: {} %".format(n_h, accuracy))

That is a question of how the plot_decision_boundary function works. You can read the code by clicking “File → Open” and then opening the appropriate python file (see the “import” cell early in the notebook to know the name of the file). (BTW how to find utility functions is one of the topics on the DLS FAQ Thread).

It also helps to understand how python “lambda” functions work. Are you familiar with that?