What does the @ (operator?) do?

Hey there,
I’m currently doing the Machine Learning Specialization, Week 2 and in the lab C1_W2_Lab04_FeatEng_PolyReg_Soln “@” is used in ln 6:

model_w,model_b = run_gradient_descent_feng(X, y, iterations=10000, alpha=1e-7)

plt.scatter(x, y, marker=‘x’, c=‘r’, label=“Actual Value”); plt.title(“x, x2, x3 features”)
plt.plot(x, X@model_w + model_b, label=“Predicted Value”); plt.xlabel(“x”); plt.ylabel(“y”); plt.legend(); plt.show()

=> After checking with Google/ Stackoverflow I’m assuming this is some kind of operator that can be defined somehow, but I can’t find out where exactly it is defined. It is also used in the lab_utils_multi.py file that is imported (and there it looks like a simple matrix multiplication), but I don’t understand where this is defined/ how this works.

Would love some feedback on this:)

Cheers from Berlin,

Hi @Daniel_Breyer

Welcome to the community.

I Assume that you are referring to a Python decorator operator.

1 Like

@Daniel_Breyer should be looking for np.matmul.

Yes, and can have a different meaning depending on the cases which are listed in the above linked page.



Thank you @rmwkwok