Evaluate one scalar tanh neuron using the supplied input vector, aligned weights, and scalar bias.
a=i=1∑nwixi+b y=tanh(a)Here n is the vector length, x is inputs, w is weights, i indexes their entries, b is bias, a is the preactivation, and y is the neuron output. For empty input and weight vectors, a equals b.
Return a tuple of two zero-dimensional PyTorch tensors: a first, then y. Both must preserve the inputs’ floating-point dtype and device.
Input: inputs = [2, 0], weights = [-3, 1], bias = 6.881373587
Output: (0.881374, 0.707107)
Explanation: The weighted inputs sum to -6; adding the bias gives the preactivation.
Input: inputs = [1.5], weights = [2], bias = -0.5
Output: (2.5, 0.986614)
Input: inputs = [], weights = [], bias = 0.75
Output: (0.75, 0.635149)
torch.sum reduces a vector to a scalar tensor, including an empty vector.
torch.tanh accepts a zero-dimensional tensor.
Accepts: array
Accepts: array
Accepts: number
Evaluate one scalar tanh neuron using the supplied input vector, aligned weights, and scalar bias.
a=i=1∑nwixi+b y=tanh(a)Here n is the vector length, x is inputs, w is weights, i indexes their entries, b is bias, a is the preactivation, and y is the neuron output. For empty input and weight vectors, a equals b.
Return a tuple of two zero-dimensional PyTorch tensors: a first, then y. Both must preserve the inputs’ floating-point dtype and device.
Input: inputs = [2, 0], weights = [-3, 1], bias = 6.881373587
Output: (0.881374, 0.707107)
Explanation: The weighted inputs sum to -6; adding the bias gives the preactivation.
Input: inputs = [1.5], weights = [2], bias = -0.5
Output: (2.5, 0.986614)
Input: inputs = [], weights = [], bias = 0.75
Output: (0.75, 0.635149)
torch.sum reduces a vector to a scalar tensor, including an empty vector.
torch.tanh accepts a zero-dimensional tensor.
Accepts: array
Accepts: array
Accepts: number