I was looking at the example:
and has the line:
# Forward pass: compute predicted y using operations on Variables; these
# are exactly the same operations we used to compute the forward pass using
# Tensors, but we do not need to keep references to intermediate values since
# we are not implementing the backward pass by hand.
y_pred = x.mm(w1).clamp(min=0).mm(w2)
I read the documentation for clamp:
torch.clamp(input, min, max, out=None) → Tensor
Clamp all elements in input into the range [min, max] and return a resulting Tensor.
but it didn't make sense to me. Why do we need to do such a weird thing? Tensorflow doesn't "clamp" anything during matrix multiplication why does pytorch?