The following code does work for direct multiplication btw two row vectors of the same shape. But, it’s conceptually wrong.
Dot product can only be conducted for a row vector and a column vector in the same length, as implemented in the np.dot(), torch.mm(), and torch.matmul() functions.
So, I wonder why NumPy and PyTorch allow this in the software design in the first place which could lead to confusion for beginners.
import torch

features = torch.randn((1, 5))
weights = torch.randn_like(features)
bias = torch.randn((1, 1))

output_sum = activation(torch.sum(features * weights) + bias)
# output_sum = activation((features * weights).sum() + bias)

Output:
tensor([[0.1595]])