#make a model for plotting routines to call
model_predict_s = lambda Xl: np.argmax(tf.nn.softmax(model_s.predict(Xl)).numpy(),axis=1)
plt_nn(model_predict_s,X_train,y_train, classes, X_cv, y_cv, suptitle=“Simple Model”)

I don’t understand how the lambda function works here. Kindly help me with an explanation.

In this code, model_predict_s is a lambda function that takes input Xl and returns the index of the class with the highest probability predicted by the model model_s for the input Xl.

The tf.nn.softmax function is applied to the output of model_s.predict(Xl) to convert the model’s raw output into probabilities, and np.argmax is then used to find the index of the class with the highest probability.

A lambda function in Python is a way to create small, anonymous functions. They are defined using the lambda keyword, followed by a list of parameters, a colon, and then the expression to be evaluated (lambda arguments : expression). These functions can take any number of arguments, but can only have one expression.