concept

Frozen feature extractor and task head

Keep the feature transformation fixed and update the task head using the training gradient. In real frameworks verify trainable parameters, mode-dependent state, and held-out performance. The scalar example is not a pretrained model.

Formal Syntax & Structure

artificial-intelligence syntaxartificial-intelligence
weight = head_step(training_rows, weight, rate)

Working Example

Example Snippetartificial-intelligence
def frozen_feature(x):    return 2 * x
def head_step(rows, weight, rate):    if not rows:        raise ValueError("Need training examples")    grad = sum(2 * (weight*frozen_feature(x)-y)*frozen_feature(x)               for x, y in rows) / len(rows)    return weight - rate * grad
def predict(x, weight):    return weight * frozen_feature(x)
weight = head_step([(1, 6)], 1, 0.125)print(weight, predict(1, weight))print(predict(2, weight))