#387The no-memory baselineEasy

The no-memory baseline

Background

The naive way to apply a static network to a sequence is to run the same function on each timestep independently — no memory of the past:

yt=ϕ(w⊤xt+b)for each t,y_t = \phi(\mathbf{w}^\top \mathbf{x}_t + b) \quad \text{for each } t,

with ϕ=tanh⁡\phi = \tanh. Every output depends only on its own input, which is exactly what recurrence will later fix.

Problem statement

Implement per_timestep(X, w, b) applying tanh⁡(w⊤xt+b)\tanh(\mathbf{w}^\top\mathbf{x}_t + b) to each timestep independently.

Input

  • X — array-like of shape (T, D): one input vector per timestep.
  • w — array-like of length D.
  • b — float.

Output

Returns an np.ndarray of shape (T,): one output per timestep.

Examples

Example 1

Input:  X = [[1], [2], [3]], w = [1], b = 0
Output: [0.76159416 0.96402758 0.99505475]

Explanation: tanh⁡(1),tanh⁡(2),tanh⁡(3)\tanh(1), \tanh(2), \tanh(3) — each from its own input only.

Constraints

  • For each row x_t, compute tanh(w · x_t + b).
  • Outputs are independent across time (no state carried).
  • Return shape (T,).

Notes

  • Because each yty_t ignores every other timestep, this model can't tell [up, up] from [up, down] at the same final point — the motivation for adding a hidden state.
Python
Loading...

▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.

  • •example per timestep
  • •reference multifeature
  • •sample with bias