Yeah, size() and shape are interchangeable.
Whatever the issue is further up the line. Specifically, whatever is producing y_val. There’s not enough information here to go off of. Could you post a snippet of the code that produces y_val?