FunctionRacerProblemsRace

Unit Rows

MediumPyTorchPython

Scale each row of the 2-D tensor x so that its length becomes 1. The length of a row is the square root of the sum of the squares of its elements.

Example 1

x [[3.0,4.0],[0.0,2.0]]
returns [[0.6,0.8],[0.0,1.0]]

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More PyTorch problems